mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-27 07:46:24 -04:00
added lcd_getstringsize() within the propfonts test define
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1124 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
7826fc39f2
commit
788f1ceae2
1 changed files with 28 additions and 0 deletions
|
|
@ -492,6 +492,34 @@ void lcd_setmargins(int x, int y)
|
||||||
|
|
||||||
extern unsigned char char_dw_8x8_prop[][9];
|
extern unsigned char char_dw_8x8_prop[][9];
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return width and height of a given font.
|
||||||
|
*/
|
||||||
|
void lcd_getstringsize(char *str, unsigned int font, int *w, int *h)
|
||||||
|
{
|
||||||
|
(void)font;
|
||||||
|
int width=0;
|
||||||
|
int height=0;
|
||||||
|
unsigned char ch, byte;
|
||||||
|
|
||||||
|
while((ch = *str++)) {
|
||||||
|
/* Limit to char generation table */
|
||||||
|
if ((ch < ASCII_MIN) || (ch > 0x7a))
|
||||||
|
/* replace unsupported letters with question marks */
|
||||||
|
ch = ' '-ASCII_MIN;
|
||||||
|
else
|
||||||
|
ch -= ASCII_MIN;
|
||||||
|
|
||||||
|
byte = char_dw_8x8_prop[ch][8];
|
||||||
|
width += byte>>4;
|
||||||
|
if((byte & 0x0f) > height)
|
||||||
|
height = byte & 0x0f;
|
||||||
|
|
||||||
|
}
|
||||||
|
*w = width;
|
||||||
|
*h = height;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Put a string at specified bit position
|
* Put a string at specified bit position
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue