Add extra-small font for large amounts of text
This commit is contained in:
parent
1802542fa0
commit
bdd8c3fae3
|
@ -16,6 +16,11 @@
|
|||
"targetPlatforms": null,
|
||||
"name": "APP_ICON_IDENTIFIER",
|
||||
"file": "images/appicon.png"
|
||||
},
|
||||
{
|
||||
"type": "font",
|
||||
"file": "fonts/Inconsolata-Regular.ttf",
|
||||
"name": "FONT_TINY_11"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
38
src/calc.c
38
src/calc.c
|
@ -118,6 +118,7 @@ static void cycle_tokens(ClickRecognizerRef recognizer, void *context)
|
|||
updateText();
|
||||
}
|
||||
|
||||
static GFont tiny_font;
|
||||
static const char *fonts[] = {
|
||||
FONT_KEY_GOTHIC_28_BOLD,
|
||||
FONT_KEY_GOTHIC_24_BOLD,
|
||||
|
@ -136,12 +137,18 @@ static void adjustFont()
|
|||
size += 10;
|
||||
size++;
|
||||
}
|
||||
int f = size < 50 ? smallestFont - 3 :
|
||||
size < 80 ? smallestFont - 2 :
|
||||
size < 100 ? smallestFont - 1 :
|
||||
smallestFont;
|
||||
text_layer_set_font(s_input_text_layer,
|
||||
fonts_get_system_font(fonts[f]));
|
||||
// Use various system fonts for most text
|
||||
if(size <= 100) {
|
||||
int f = size < 50 ? smallestFont - 3 :
|
||||
size < 80 ? smallestFont - 2 :
|
||||
size < 100 ? smallestFont - 1 :
|
||||
smallestFont;
|
||||
text_layer_set_font(s_input_text_layer,
|
||||
fonts_get_system_font(fonts[f]));
|
||||
} else {
|
||||
// Use custom extra small font for lots of text
|
||||
text_layer_set_font(s_input_text_layer, tiny_font);
|
||||
}
|
||||
}
|
||||
|
||||
static void custom_unload(Window *window)
|
||||
|
@ -240,13 +247,14 @@ static void code_click_subscribe(void *context)
|
|||
}
|
||||
|
||||
#define FORCE_TEXT \
|
||||
"(def time (fn (a) (utl tt "\
|
||||
"(cat (hrt 0 0) \":\" (mnt 0 0))" \
|
||||
")))" \
|
||||
"(def ww (cw 0 0))" \
|
||||
"(def tt (atl ww \"OI\"))" \
|
||||
"(pw ww 0)" \
|
||||
"(sub time 0)"
|
||||
"(def time (fn () ((def m (mnt)) (utl tt \n"\
|
||||
" (cat \"Hey, it's \"\n"\
|
||||
" (hrt) \":\" (if (< m 10) \"0\" \"\") m)\n"\
|
||||
"))))\n" \
|
||||
"(def ww (cw))\n" \
|
||||
"(def tt (atl ww \":\"))\n" \
|
||||
"(pw ww)\n" \
|
||||
"(sub time 2)"
|
||||
|
||||
// Remove to re-enable
|
||||
#undef FORCE_TEXT
|
||||
|
@ -266,7 +274,7 @@ static void code_window_load(Window *window)
|
|||
layer_add_child(window_get_root_layer(s_code_window), text_layer_get_layer(s_input_text_layer));
|
||||
|
||||
// Result text layer setup
|
||||
GRect result_bounds = GRect(6, 128, 132, 132);
|
||||
GRect result_bounds = GRect(6, 148, 132, 132);
|
||||
s_result_text_layer = text_layer_create(result_bounds);
|
||||
text_layer_set_text(s_result_text_layer, "R: ");
|
||||
text_layer_set_font(s_result_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD));
|
||||
|
@ -452,7 +460,6 @@ static void inbox_received_callback(DictionaryIterator *iter, void *context) {
|
|||
static struct Environment pebbleEnv()
|
||||
{
|
||||
struct Environment e = defaultEnv();
|
||||
// Needs two args
|
||||
addFunc("window", &add_window, &e);
|
||||
addFunc("sc", &run_script, &e);
|
||||
addFunc("cw", &createWindow, &e);
|
||||
|
@ -492,6 +499,7 @@ static void deinit(void)
|
|||
int main(void)
|
||||
{
|
||||
init();
|
||||
tiny_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_TINY_11));
|
||||
app_event_loop();
|
||||
deinit();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue