From cf8f526d16d8c37768e44c56c8985f30293bda4a Mon Sep 17 00:00:00 2001 From: Fred Bauer Date: Fri, 27 Aug 2010 18:25:23 +0000 Subject: change get_glyph_size() to font_glyphs_to_bufsize(). fixes a bug when font glyph buffer < font header git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27911 a1c6a512-1295-4272-9138-f99709370657 --- firmware/font.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'firmware/font.c') 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) return; } -int get_glyph_size(const char *path) +int font_glyphs_to_bufsize(const char *path, int glyphs) { struct font f; - int overhead; + int bufsize; char buf[FONT_HEADER_SIZE]; f.buffer_start = buf; @@ -656,9 +656,13 @@ int get_glyph_size(const char *path) } close(f.fd); - overhead = LRU_SLOT_OVERHEAD + sizeof(struct font_cache_entry) + + bufsize = LRU_SLOT_OVERHEAD + sizeof(struct font_cache_entry) + sizeof( unsigned short); - return overhead + (f.maxwidth * ((f.height + 7) / 8)); + bufsize += f.maxwidth * ((f.height + 7) / 8); + bufsize *= glyphs; + if ( bufsize < FONT_HEADER_SIZE ) + bufsize = FONT_HEADER_SIZE; + return bufsize; } static int ushortcmp(const void *a, const void *b) -- cgit