summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFred Bauer <fred.w.bauer@gmail.com>2010-08-27 18:25:23 +0000
committerFred Bauer <fred.w.bauer@gmail.com>2010-08-27 18:25:23 +0000
commitcf8f526d16d8c37768e44c56c8985f30293bda4a (patch)
treed47718fe08256ae887a686c7d656c9ae29809b21
parentaaa864ea0314c1619b2b1caf29c8921a7714e751 (diff)
downloadrockbox-cf8f526d16d8c37768e44c56c8985f30293bda4a.tar.gz
rockbox-cf8f526d16d8c37768e44c56c8985f30293bda4a.zip
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
-rw-r--r--apps/gui/skin_engine/skin_fonts.c2
-rw-r--r--firmware/export/font.h2
-rw-r--r--firmware/font.c12
3 files changed, 10 insertions, 6 deletions
diff --git a/apps/gui/skin_engine/skin_fonts.c b/apps/gui/skin_engine/skin_fonts.c
index 56a87ca93c..128bffcfba 100644
--- a/apps/gui/skin_engine/skin_fonts.c
+++ b/apps/gui/skin_engine/skin_fonts.c
@@ -96,7 +96,7 @@ int skin_font_load(char* font_name, int glyphs)
96 if (!glyphs) 96 if (!glyphs)
97 glyphs = GLYPHS_TO_CACHE; 97 glyphs = GLYPHS_TO_CACHE;
98#ifndef __PCTOOL__ 98#ifndef __PCTOOL__
99 skin_font_size = glyphs * get_glyph_size(filename); 99 skin_font_size = font_glyphs_to_bufsize(filename, glyphs);
100#endif 100#endif
101 if ( !skin_font_size ) 101 if ( !skin_font_size )
102 { 102 {
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;
121int font_load_remoteui(const char* path); 121int font_load_remoteui(const char* path);
122#endif 122#endif
123int font_load(struct font* pf, const char *path); 123int font_load(struct font* pf, const char *path);
124int get_glyph_size(const char *path); 124int font_glyphs_to_bufsize(const char *path, int glyphs);
125void font_unload(int font_id); 125void font_unload(int font_id);
126 126
127struct font* font_get(int font); 127struct 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
635int get_glyph_size(const char *path) 635int 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
664static int ushortcmp(const void *a, const void *b) 668static int ushortcmp(const void *a, const void *b)