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