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.zip
rockbox-cf8f526d16d8c37768e44c56c8985f30293bda4a.tar.gz
rockbox-cf8f526d16d8c37768e44c56c8985f30293bda4a.tar.bz2
rockbox-cf8f526d16d8c37768e44c56c8985f30293bda4a.tar.xz
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 56a87ca..128bffc 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)
if (!glyphs)
glyphs = GLYPHS_TO_CACHE;
#ifndef __PCTOOL__
- skin_font_size = glyphs * get_glyph_size(filename);
+ skin_font_size = font_glyphs_to_bufsize(filename, glyphs);
#endif
if ( !skin_font_size )
{
diff --git a/firmware/export/font.h b/firmware/export/font.h
index 4aa99e4..0a75768 100644
--- a/firmware/export/font.h
+++ b/firmware/export/font.h
@@ -121,7 +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);
+int font_glyphs_to_bufsize(const char *path, int glyphs);
void font_unload(int font_id);
struct font* font_get(int font);
diff --git a/firmware/font.c b/firmware/font.c
index 7dbc5a2..e973108 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)