mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 02:27:39 -04:00
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
This commit is contained in:
parent
aaa864ea03
commit
cf8f526d16
3 changed files with 10 additions and 6 deletions
|
@ -96,7 +96,7 @@ int skin_font_load(char* font_name, int glyphs)
|
||||||
if (!glyphs)
|
if (!glyphs)
|
||||||
glyphs = GLYPHS_TO_CACHE;
|
glyphs = GLYPHS_TO_CACHE;
|
||||||
#ifndef __PCTOOL__
|
#ifndef __PCTOOL__
|
||||||
skin_font_size = glyphs * get_glyph_size(filename);
|
skin_font_size = font_glyphs_to_bufsize(filename, glyphs);
|
||||||
#endif
|
#endif
|
||||||
if ( !skin_font_size )
|
if ( !skin_font_size )
|
||||||
{
|
{
|
||||||
|
|
|
@ -121,7 +121,7 @@ void font_init(void) INIT_ATTR;
|
||||||
int font_load_remoteui(const char* path);
|
int font_load_remoteui(const char* path);
|
||||||
#endif
|
#endif
|
||||||
int font_load(struct font* pf, const char *path);
|
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);
|
void font_unload(int font_id);
|
||||||
|
|
||||||
struct font* font_get(int font);
|
struct font* font_get(int font);
|
||||||
|
|
|
@ -632,10 +632,10 @@ void glyph_cache_save(struct font* pf)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_glyph_size(const char *path)
|
int font_glyphs_to_bufsize(const char *path, int glyphs)
|
||||||
{
|
{
|
||||||
struct font f;
|
struct font f;
|
||||||
int overhead;
|
int bufsize;
|
||||||
char buf[FONT_HEADER_SIZE];
|
char buf[FONT_HEADER_SIZE];
|
||||||
|
|
||||||
f.buffer_start = buf;
|
f.buffer_start = buf;
|
||||||
|
@ -656,9 +656,13 @@ int get_glyph_size(const char *path)
|
||||||
}
|
}
|
||||||
close(f.fd);
|
close(f.fd);
|
||||||
|
|
||||||
overhead = LRU_SLOT_OVERHEAD + sizeof(struct font_cache_entry) +
|
bufsize = LRU_SLOT_OVERHEAD + sizeof(struct font_cache_entry) +
|
||||||
sizeof( unsigned short);
|
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)
|
static int ushortcmp(const void *a, const void *b)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue