summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/export/font.h1
-rw-r--r--firmware/font.c29
2 files changed, 30 insertions, 0 deletions
diff --git a/firmware/export/font.h b/firmware/export/font.h
index 7284564380..4aa99e4d05 100644
--- a/firmware/export/font.h
+++ b/firmware/export/font.h
@@ -121,6 +121,7 @@ void font_init(void) INIT_ATTR;
int font_load_remoteui(const char* path);
#endif
int font_load(struct font* pf, const char *path);
+int get_glyph_size(const char *path);
void font_unload(int font_id);
struct font* font_get(int font);
diff --git a/firmware/font.c b/firmware/font.c
index d4f0dfa77a..98bd6399fe 100644
--- a/firmware/font.c
+++ b/firmware/font.c
@@ -628,6 +628,35 @@ void glyph_cache_save(struct font* pf)
return;
}
+int get_glyph_size(const char *path)
+{
+ struct font f;
+ int overhead;
+ char buf[FONT_HEADER_SIZE];
+
+ f.buffer_start = buf;
+ f.buffer_size = sizeof(buf);
+ f.buffer_position = buf;
+
+ f.fd = open(path, O_RDONLY|O_BINARY);
+ if(f.fd < 0)
+ return 0;
+
+ read(f.fd, f.buffer_position, FONT_HEADER_SIZE);
+ f.buffer_end = f.buffer_position + FONT_HEADER_SIZE;
+
+ if( !font_load_header(&f) )
+ {
+ close(f.fd);
+ return 0;
+ }
+ close(f.fd);
+
+ overhead = LRU_SLOT_OVERHEAD + sizeof(struct font_cache_entry) +
+ sizeof( unsigned short);
+ return overhead + (f.maxwidth * ((f.height + 7) / 8));
+}
+
static int ushortcmp(const void *a, const void *b)
{
return ((int)(*(unsigned short*)a - *(unsigned short*)b));