diff options
-rw-r--r-- | firmware/drivers/lcd.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/firmware/drivers/lcd.c b/firmware/drivers/lcd.c index d09d7ed1a5..8c24fc7b7d 100644 --- a/firmware/drivers/lcd.c +++ b/firmware/drivers/lcd.c | |||
@@ -493,6 +493,34 @@ void lcd_setmargins(int x, int y) | |||
493 | extern unsigned char char_dw_8x8_prop[][9]; | 493 | extern unsigned char char_dw_8x8_prop[][9]; |
494 | 494 | ||
495 | /* | 495 | /* |
496 | * Return width and height of a given font. | ||
497 | */ | ||
498 | void lcd_getstringsize(char *str, unsigned int font, int *w, int *h) | ||
499 | { | ||
500 | (void)font; | ||
501 | int width=0; | ||
502 | int height=0; | ||
503 | unsigned char ch, byte; | ||
504 | |||
505 | while((ch = *str++)) { | ||
506 | /* Limit to char generation table */ | ||
507 | if ((ch < ASCII_MIN) || (ch > 0x7a)) | ||
508 | /* replace unsupported letters with question marks */ | ||
509 | ch = ' '-ASCII_MIN; | ||
510 | else | ||
511 | ch -= ASCII_MIN; | ||
512 | |||
513 | byte = char_dw_8x8_prop[ch][8]; | ||
514 | width += byte>>4; | ||
515 | if((byte & 0x0f) > height) | ||
516 | height = byte & 0x0f; | ||
517 | |||
518 | } | ||
519 | *w = width; | ||
520 | *h = height; | ||
521 | } | ||
522 | |||
523 | /* | ||
496 | * Put a string at specified bit position | 524 | * Put a string at specified bit position |
497 | */ | 525 | */ |
498 | 526 | ||