diff options
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/export/font.h | 5 | ||||
-rw-r--r-- | firmware/font.c | 75 |
2 files changed, 20 insertions, 60 deletions
diff --git a/firmware/export/font.h b/firmware/export/font.h index 76f86c845f..914d3aa2ff 100644 --- a/firmware/export/font.h +++ b/firmware/export/font.h | |||
@@ -55,7 +55,7 @@ enum { | |||
55 | 55 | ||
56 | /* SYSFONT, FONT_UI, FONT_UI_REMOTE + MAXUSERFONTS fonts in skins */ | 56 | /* SYSFONT, FONT_UI, FONT_UI_REMOTE + MAXUSERFONTS fonts in skins */ |
57 | #define MAXFONTS (FONT_FIRSTUSERFONT + MAXUSERFONTS) | 57 | #define MAXFONTS (FONT_FIRSTUSERFONT + MAXUSERFONTS) |
58 | #define FONT_UI MAXUSERFONTS | 58 | #define FONT_UI MAXFONTS |
59 | 59 | ||
60 | /* | 60 | /* |
61 | * .fnt loadable font file format definition | 61 | * .fnt loadable font file format definition |
@@ -124,9 +124,6 @@ int font_glyphs_to_bufsize(const char *path, int glyphs); | |||
124 | void font_unload(int font_id); | 124 | void font_unload(int font_id); |
125 | void font_unload_all(void); | 125 | void font_unload_all(void); |
126 | void font_lock(int font_id, bool lock); | 126 | void font_lock(int font_id, bool lock); |
127 | /* set the default UI font */ | ||
128 | void font_set_ui(int font_id); | ||
129 | int font_get_ui(void); | ||
130 | 127 | ||
131 | struct font* font_get(int font); | 128 | struct font* font_get(int font); |
132 | 129 | ||
diff --git a/firmware/font.c b/firmware/font.c index 8e576016bd..ff5bc4b008 100644 --- a/firmware/font.c +++ b/firmware/font.c | |||
@@ -88,7 +88,6 @@ struct buflib_alloc_data { | |||
88 | }; | 88 | }; |
89 | static int buflib_allocations[MAXFONTS]; | 89 | static int buflib_allocations[MAXFONTS]; |
90 | 90 | ||
91 | static int font_ui = -1; | ||
92 | static int cache_fd; | 91 | static int cache_fd; |
93 | static struct font* cache_pf; | 92 | static struct font* cache_pf; |
94 | 93 | ||
@@ -560,7 +559,7 @@ int font_load_ex(const char *path, size_t buffer_size) | |||
560 | 559 | ||
561 | lock_font_handle(handle, false); | 560 | lock_font_handle(handle, false); |
562 | buflib_allocations[font_id] = handle; | 561 | buflib_allocations[font_id] = handle; |
563 | //printf("%s -> [%d] -> %d\n", path, font_id, handle); | 562 | //printf("%s -> [%d] -> %d\n", path, font_id, *handle); |
564 | return font_id; /* success!*/ | 563 | return font_id; /* success!*/ |
565 | } | 564 | } |
566 | int font_load(const char *path) | 565 | int font_load(const char *path) |
@@ -617,52 +616,28 @@ void font_unload_all(void) | |||
617 | 616 | ||
618 | /* | 617 | /* |
619 | * Return a pointer to an incore font structure. | 618 | * Return a pointer to an incore font structure. |
620 | * Return the requested font, font_ui, or sysfont | 619 | * If the requested font isn't loaded/compiled-in, |
620 | * decrement the font number and try again. | ||
621 | */ | 621 | */ |
622 | struct font* font_get(int font_id) | 622 | struct font* font_get(int font) |
623 | { | 623 | { |
624 | struct buflib_alloc_data *alloc; | 624 | struct font* pf; |
625 | struct font *pf; | 625 | if (font == FONT_UI) |
626 | int handle, id=-1; | 626 | font = MAXFONTS-1; |
627 | 627 | if (font <= FONT_SYSFIXED) | |
628 | if( font_id == FONT_UI ) | ||
629 | id = font_ui; | ||
630 | |||
631 | if( font_id == FONT_SYSFIXED ) | ||
632 | return &sysfont; | 628 | return &sysfont; |
633 | |||
634 | if( id == -1 ) | ||
635 | id = font_id; | ||
636 | |||
637 | handle = buflib_allocations[id]; | ||
638 | if( handle > 0 ) | ||
639 | { | ||
640 | alloc = core_get_data(buflib_allocations[id]); | ||
641 | pf=&alloc->font; | ||
642 | if( pf && pf->height ) | ||
643 | return pf; | ||
644 | } | ||
645 | handle = buflib_allocations[font_ui]; | ||
646 | if( handle > 0 ) | ||
647 | { | ||
648 | alloc = core_get_data(buflib_allocations[font_ui]); | ||
649 | pf=&alloc->font; | ||
650 | if( pf && pf->height ) | ||
651 | return pf; | ||
652 | } | ||
653 | |||
654 | return &sysfont; | ||
655 | } | ||
656 | |||
657 | void font_set_ui( int font_id ) | ||
658 | { | ||
659 | font_ui = font_id; | ||
660 | return; | ||
661 | } | ||
662 | 629 | ||
663 | int font_get_ui() | 630 | while (1) { |
664 | { | 631 | if (buflib_allocations[font] > 0) |
665 | return font_ui; | 632 | { |
633 | struct buflib_alloc_data *alloc = core_get_data(buflib_allocations[font]); | ||
634 | pf = &alloc->font; | ||
635 | if (pf && pf->height) | ||
636 | return pf; | ||
637 | } | ||
638 | if (--font < 0) | ||
639 | return &sysfont; | ||
640 | } | ||
666 | } | 641 | } |
667 | 642 | ||
668 | static int pf_to_handle(struct font* pf) | 643 | static int pf_to_handle(struct font* pf) |
@@ -1004,18 +979,6 @@ struct font* font_get(int font) | |||
1004 | return &sysfont; | 979 | return &sysfont; |
1005 | } | 980 | } |
1006 | 981 | ||
1007 | void font_set_ui(int font_id) | ||
1008 | { | ||
1009 | (void)font_id; | ||
1010 | return; | ||
1011 | } | ||
1012 | |||
1013 | int font_get_ui() | ||
1014 | { | ||
1015 | return FONT_SYSFIXED; | ||
1016 | } | ||
1017 | |||
1018 | |||
1019 | /* | 982 | /* |
1020 | * Returns width of character | 983 | * Returns width of character |
1021 | */ | 984 | */ |