diff options
author | Christian Gmeiner <christian.gmeiner@gmail.com> | 2005-04-19 12:47:16 +0000 |
---|---|---|
committer | Christian Gmeiner <christian.gmeiner@gmail.com> | 2005-04-19 12:47:16 +0000 |
commit | c6ec0f48a5999c4456439eb4e0b54467b464ed02 (patch) | |
tree | 5ef7e0368a7863c07500f1f89991ae6551c1a530 /firmware | |
parent | ed0c8764c44ca5d651b08fdd19bb2597f3a8300b (diff) | |
download | rockbox-c6ec0f48a5999c4456439eb4e0b54467b464ed02.tar.gz rockbox-c6ec0f48a5999c4456439eb4e0b54467b464ed02.zip |
moved lcd_getstringsize into font.c
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6321 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/drivers/lcd-h100.c | 19 | ||||
-rw-r--r-- | firmware/export/font.h | 1 | ||||
-rw-r--r-- | firmware/font.c | 25 |
3 files changed, 27 insertions, 18 deletions
diff --git a/firmware/drivers/lcd-h100.c b/firmware/drivers/lcd-h100.c index d27a62da41..157791d991 100644 --- a/firmware/drivers/lcd-h100.c +++ b/firmware/drivers/lcd-h100.c | |||
@@ -319,24 +319,7 @@ void lcd_setfont(int newfont) | |||
319 | 319 | ||
320 | int lcd_getstringsize(const unsigned char *str, int *w, int *h) | 320 | int lcd_getstringsize(const unsigned char *str, int *w, int *h) |
321 | { | 321 | { |
322 | struct font* pf = font_get(curfont); | 322 | return font_getstringsize(str, w, h, curfont); |
323 | int ch; | ||
324 | int width = 0; | ||
325 | |||
326 | while((ch = *str++)) { | ||
327 | /* check input range*/ | ||
328 | if (ch < pf->firstchar || ch >= pf->firstchar+pf->size) | ||
329 | ch = pf->defaultchar; | ||
330 | ch -= pf->firstchar; | ||
331 | |||
332 | /* get proportional width and glyph bits*/ | ||
333 | width += pf->width? pf->width[ch]: pf->maxwidth; | ||
334 | } | ||
335 | if ( w ) | ||
336 | *w = width; | ||
337 | if ( h ) | ||
338 | *h = pf->height; | ||
339 | return width; | ||
340 | } | 323 | } |
341 | 324 | ||
342 | /* put a string at a given char position */ | 325 | /* put a string at a given char position */ |
diff --git a/firmware/export/font.h b/firmware/export/font.h index 8b3f373245..01751add5c 100644 --- a/firmware/export/font.h +++ b/firmware/export/font.h | |||
@@ -91,6 +91,7 @@ void font_init(void); | |||
91 | struct font* font_load(const char *path); | 91 | struct font* font_load(const char *path); |
92 | struct font* font_get(int font); | 92 | struct font* font_get(int font); |
93 | void font_reset(void); | 93 | void font_reset(void); |
94 | int font_getstringsize(const unsigned char *str, int *w, int *h, int fontnumber); | ||
94 | 95 | ||
95 | #else /* HAVE_LCD_BITMAP */ | 96 | #else /* HAVE_LCD_BITMAP */ |
96 | 97 | ||
diff --git a/firmware/font.c b/firmware/font.c index 37c082f583..303887701d 100644 --- a/firmware/font.c +++ b/firmware/font.c | |||
@@ -225,6 +225,31 @@ struct font* font_get(int font) | |||
225 | panicf("No font!"); | 225 | panicf("No font!"); |
226 | } | 226 | } |
227 | } | 227 | } |
228 | /* | ||
229 | * Returns the stringsize of a given string. | ||
230 | */ | ||
231 | int font_getstringsize(const unsigned char *str, int *w, int *h, int fontnumber) | ||
232 | { | ||
233 | struct font* pf = font_get(fontnumber); | ||
234 | int ch; | ||
235 | int width = 0; | ||
236 | |||
237 | while((ch = *str++)) { | ||
238 | /* check input range*/ | ||
239 | if (ch < pf->firstchar || ch >= pf->firstchar+pf->size) | ||
240 | ch = pf->defaultchar; | ||
241 | ch -= pf->firstchar; | ||
242 | |||
243 | /* get proportional width and glyph bits*/ | ||
244 | width += pf->width? pf->width[ch]: pf->maxwidth; | ||
245 | } | ||
246 | if ( w ) | ||
247 | *w = width; | ||
248 | if ( h ) | ||
249 | *h = pf->height; | ||
250 | return width; | ||
251 | } | ||
252 | |||
228 | 253 | ||
229 | #endif /* HAVE_LCD_BITMAP */ | 254 | #endif /* HAVE_LCD_BITMAP */ |
230 | 255 | ||