Trammell Hudson avatar Trammell Hudson committed 43494bf

Only call fonts_load_custom_font() once per font

Comments (0)

Files changed (1)

words/src/words.c

 #define FONT_W 12
 #define FONT_ON		RESOURCE_ID_FONT_COURIER_BOLD_20
 #define FONT_OFF	RESOURCE_ID_FONT_COURIER_20
-
+static GFont font_on;
+static GFont font_off;
 
 typedef struct
 {
 
 	text_layer_set_font(
 		layer,
-		fonts_load_custom_font(resource_get_handle(on ? FONT_ON : FONT_OFF))
+		on ? font_on : font_off
 	);
 }
 
 	TextLayer * const layer = &layers[which];
 	const word_t * const w = &words[which];
 
+	font_on = fonts_load_custom_font(resource_get_handle(FONT_ON));
+	font_off = fonts_load_custom_font(resource_get_handle(FONT_OFF));
+
 	GRect frame = GRect(
 		w->col*FONT_W,
 		w->row*FONT_H - 4,
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.