diff options
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/export/font.h | 2 | ||||
-rw-r--r-- | firmware/font.c | 12 |
2 files changed, 9 insertions, 5 deletions
diff --git a/firmware/export/font.h b/firmware/export/font.h index 4aa99e4d05..0a75768fa5 100644 --- a/firmware/export/font.h +++ b/firmware/export/font.h | |||
@@ -121,7 +121,7 @@ void font_init(void) INIT_ATTR; | |||
121 | int font_load_remoteui(const char* path); | 121 | int font_load_remoteui(const char* path); |
122 | #endif | 122 | #endif |
123 | int font_load(struct font* pf, const char *path); | 123 | int font_load(struct font* pf, const char *path); |
124 | int get_glyph_size(const char *path); | 124 | int font_glyphs_to_bufsize(const char *path, int glyphs); |
125 | void font_unload(int font_id); | 125 | void font_unload(int font_id); |
126 | 126 | ||
127 | struct font* font_get(int font); | 127 | struct font* font_get(int font); |
diff --git a/firmware/font.c b/firmware/font.c index 7dbc5a258a..e973108bca 100644 --- a/firmware/font.c +++ b/firmware/font.c | |||
@@ -632,10 +632,10 @@ void glyph_cache_save(struct font* pf) | |||
632 | return; | 632 | return; |
633 | } | 633 | } |
634 | 634 | ||
635 | int get_glyph_size(const char *path) | 635 | int font_glyphs_to_bufsize(const char *path, int glyphs) |
636 | { | 636 | { |
637 | struct font f; | 637 | struct font f; |
638 | int overhead; | 638 | int bufsize; |
639 | char buf[FONT_HEADER_SIZE]; | 639 | char buf[FONT_HEADER_SIZE]; |
640 | 640 | ||
641 | f.buffer_start = buf; | 641 | f.buffer_start = buf; |
@@ -656,9 +656,13 @@ int get_glyph_size(const char *path) | |||
656 | } | 656 | } |
657 | close(f.fd); | 657 | close(f.fd); |
658 | 658 | ||
659 | overhead = LRU_SLOT_OVERHEAD + sizeof(struct font_cache_entry) + | 659 | bufsize = LRU_SLOT_OVERHEAD + sizeof(struct font_cache_entry) + |
660 | sizeof( unsigned short); | 660 | sizeof( unsigned short); |
661 | return overhead + (f.maxwidth * ((f.height + 7) / 8)); | 661 | bufsize += f.maxwidth * ((f.height + 7) / 8); |
662 | bufsize *= glyphs; | ||
663 | if ( bufsize < FONT_HEADER_SIZE ) | ||
664 | bufsize = FONT_HEADER_SIZE; | ||
665 | return bufsize; | ||
662 | } | 666 | } |
663 | 667 | ||
664 | static int ushortcmp(const void *a, const void *b) | 668 | static int ushortcmp(const void *a, const void *b) |