Skip to content

Commit

Permalink
Use custom font.
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrissiQ committed Mar 26, 2015
1 parent c5754b4 commit e477339
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#include "main.h"

#define TIME_TEMPLATE "00:00"

#define FONT_SECONDS FONT_KEY_BITHAM_30_BLACK
#define FONT_MINUTES FONT_KEY_BITHAM_42_BOLD

Expand Down Expand Up @@ -36,20 +35,26 @@ static void tick_handler(struct tm *tick_time, TimeUnits units_changed) {

static void main_window_load(Window *window) {
// Create time TextLayer
s_time_layer = text_layer_create(GRect(0, 55, 144, 50));
s_time_layer = text_layer_create(GRect(5, 52, 139, 50));

// Create GFont
s_time_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_PERFECT_DOS_48));

text_layer_set_background_color(s_time_layer, GColorClear);
text_layer_set_text_color(s_time_layer, GColorBlack);
text_layer_set_text(s_time_layer, TIME_TEMPLATE);

// Improve the layout to be more like a watch face
text_layer_set_font(s_time_layer, fonts_get_system_font(FONT_MINUTES));
// Apply to TextLayer
text_layer_set_font(s_time_layer, s_time_font);
text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter);

// Add it as a child later to the Window's root layer
layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_time_layer));
}

static void main_window_unload(Window *window) {
fonts_unload_custom_font(s_time_font);
text_layer_destroy(s_time_layer);
}

Expand Down

0 comments on commit e477339

Please sign in to comment.