diff options
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/drivers/lcd-16bit.c | 5 | ||||
-rw-r--r-- | firmware/drivers/lcd-2bit-horz.c | 5 | ||||
-rw-r--r-- | firmware/drivers/lcd-h100-remote.c | 5 | ||||
-rw-r--r-- | firmware/drivers/lcd-h100.c | 5 | ||||
-rw-r--r-- | firmware/drivers/lcd-recorder.c | 5 | ||||
-rw-r--r-- | firmware/font.c | 29 |
6 files changed, 20 insertions, 34 deletions
diff --git a/firmware/drivers/lcd-16bit.c b/firmware/drivers/lcd-16bit.c index 08e62b828f..e98403aa1b 100644 --- a/firmware/drivers/lcd-16bit.c +++ b/firmware/drivers/lcd-16bit.c | |||
@@ -735,11 +735,6 @@ static void lcd_putsxyofs(int x, int y, int ofs, const unsigned char *str) | |||
735 | int width; | 735 | int width; |
736 | const unsigned char *bits; | 736 | const unsigned char *bits; |
737 | 737 | ||
738 | /* check input range */ | ||
739 | if (ch < pf->firstchar || ch >= pf->firstchar+pf->size) | ||
740 | ch = pf->defaultchar; | ||
741 | ch -= pf->firstchar; | ||
742 | |||
743 | /* get proportional width and glyph bits */ | 738 | /* get proportional width and glyph bits */ |
744 | width = font_get_width(pf,ch); | 739 | width = font_get_width(pf,ch); |
745 | 740 | ||
diff --git a/firmware/drivers/lcd-2bit-horz.c b/firmware/drivers/lcd-2bit-horz.c index a76ebe1f0d..bfb69da33b 100644 --- a/firmware/drivers/lcd-2bit-horz.c +++ b/firmware/drivers/lcd-2bit-horz.c | |||
@@ -703,11 +703,6 @@ static void lcd_putsxyofs(int x, int y, int ofs, const unsigned char *str) | |||
703 | int width; | 703 | int width; |
704 | const unsigned char *bits; | 704 | const unsigned char *bits; |
705 | 705 | ||
706 | /* check input range */ | ||
707 | if (ch < pf->firstchar || ch >= pf->firstchar+pf->size) | ||
708 | ch = pf->defaultchar; | ||
709 | ch -= pf->firstchar; | ||
710 | |||
711 | /* get proportional width and glyph bits */ | 706 | /* get proportional width and glyph bits */ |
712 | width = font_get_width(pf,ch); | 707 | width = font_get_width(pf,ch); |
713 | 708 | ||
diff --git a/firmware/drivers/lcd-h100-remote.c b/firmware/drivers/lcd-h100-remote.c index 58953f61b5..ffe6f1492c 100644 --- a/firmware/drivers/lcd-h100-remote.c +++ b/firmware/drivers/lcd-h100-remote.c | |||
@@ -1117,11 +1117,6 @@ static void lcd_remote_putsxyofs(int x, int y, int ofs, const unsigned char *str | |||
1117 | int width; | 1117 | int width; |
1118 | const unsigned char *bits; | 1118 | const unsigned char *bits; |
1119 | 1119 | ||
1120 | /* check input range */ | ||
1121 | if (ch < pf->firstchar || ch >= pf->firstchar+pf->size) | ||
1122 | ch = pf->defaultchar; | ||
1123 | ch -= pf->firstchar; | ||
1124 | |||
1125 | /* get proportional width and glyph bits */ | 1120 | /* get proportional width and glyph bits */ |
1126 | width = font_get_width(pf, ch); | 1121 | width = font_get_width(pf, ch); |
1127 | 1122 | ||
diff --git a/firmware/drivers/lcd-h100.c b/firmware/drivers/lcd-h100.c index 1d80458679..8a06367112 100644 --- a/firmware/drivers/lcd-h100.c +++ b/firmware/drivers/lcd-h100.c | |||
@@ -1033,11 +1033,6 @@ static void lcd_putsxyofs(int x, int y, int ofs, const unsigned char *str) | |||
1033 | int width; | 1033 | int width; |
1034 | const unsigned char *bits; | 1034 | const unsigned char *bits; |
1035 | 1035 | ||
1036 | /* check input range */ | ||
1037 | if (ch < pf->firstchar || ch >= pf->firstchar+pf->size) | ||
1038 | ch = pf->defaultchar; | ||
1039 | ch -= pf->firstchar; | ||
1040 | |||
1041 | /* get proportional width and glyph bits */ | 1036 | /* get proportional width and glyph bits */ |
1042 | width = font_get_width(pf,ch); | 1037 | width = font_get_width(pf,ch); |
1043 | 1038 | ||
diff --git a/firmware/drivers/lcd-recorder.c b/firmware/drivers/lcd-recorder.c index 7a44acf590..89b041dc3d 100644 --- a/firmware/drivers/lcd-recorder.c +++ b/firmware/drivers/lcd-recorder.c | |||
@@ -886,11 +886,6 @@ static void lcd_putsxyofs(int x, int y, int ofs, const unsigned char *str) | |||
886 | int width; | 886 | int width; |
887 | const unsigned char *bits; | 887 | const unsigned char *bits; |
888 | 888 | ||
889 | /* check input range */ | ||
890 | if (ch < pf->firstchar || ch >= pf->firstchar+pf->size) | ||
891 | ch = pf->defaultchar; | ||
892 | ch -= pf->firstchar; | ||
893 | |||
894 | /* get proportional width and glyph bits */ | 889 | /* get proportional width and glyph bits */ |
895 | width = font_get_width(pf,ch); | 890 | width = font_get_width(pf,ch); |
896 | 891 | ||
diff --git a/firmware/font.c b/firmware/font.c index d45c0e803f..5f244bcb37 100644 --- a/firmware/font.c +++ b/firmware/font.c | |||
@@ -389,10 +389,6 @@ int font_getstringsize(const unsigned char *str, int *w, int *h, int fontnumber) | |||
389 | 389 | ||
390 | for (str = utf8decode(str, &ch); ch != 0 ; str = utf8decode(str, &ch)) | 390 | for (str = utf8decode(str, &ch); ch != 0 ; str = utf8decode(str, &ch)) |
391 | { | 391 | { |
392 | /* check input range*/ | ||
393 | if (ch < pf->firstchar || ch >= pf->firstchar+pf->size) | ||
394 | ch = pf->defaultchar; | ||
395 | ch -= pf->firstchar; | ||
396 | 392 | ||
397 | /* get proportional width and glyph bits*/ | 393 | /* get proportional width and glyph bits*/ |
398 | width += font_get_width(pf,ch); | 394 | width += font_get_width(pf,ch); |
@@ -467,6 +463,11 @@ static void cache_create(int maxwidth, int height) | |||
467 | */ | 463 | */ |
468 | int font_get_width(struct font* pf, unsigned short char_code) | 464 | int font_get_width(struct font* pf, unsigned short char_code) |
469 | { | 465 | { |
466 | /* check input range*/ | ||
467 | if (char_code < pf->firstchar || char_code >= pf->firstchar+pf->size) | ||
468 | char_code = pf->defaultchar; | ||
469 | char_code -= pf->firstchar; | ||
470 | |||
470 | return (fnt_file >= 0 && pf != &sysfont)? | 471 | return (fnt_file >= 0 && pf != &sysfont)? |
471 | font_cache_get(&font_cache_ui,char_code,load_cache_entry,pf)->width: | 472 | font_cache_get(&font_cache_ui,char_code,load_cache_entry,pf)->width: |
472 | pf->width? pf->width[char_code]: pf->maxwidth; | 473 | pf->width? pf->width[char_code]: pf->maxwidth; |
@@ -475,6 +476,12 @@ int font_get_width(struct font* pf, unsigned short char_code) | |||
475 | const unsigned char* font_get_bits(struct font* pf, unsigned short char_code) | 476 | const unsigned char* font_get_bits(struct font* pf, unsigned short char_code) |
476 | { | 477 | { |
477 | const unsigned char* bits; | 478 | const unsigned char* bits; |
479 | |||
480 | /* check input range*/ | ||
481 | if (char_code < pf->firstchar || char_code >= pf->firstchar+pf->size) | ||
482 | char_code = pf->defaultchar; | ||
483 | char_code -= pf->firstchar; | ||
484 | |||
478 | if (fnt_file >= 0 && pf != &sysfont) | 485 | if (fnt_file >= 0 && pf != &sysfont) |
479 | { | 486 | { |
480 | bits = | 487 | bits = |
@@ -493,11 +500,15 @@ const unsigned char* font_get_bits(struct font* pf, unsigned short char_code) | |||
493 | void glyph_file_write(void* data) | 500 | void glyph_file_write(void* data) |
494 | { | 501 | { |
495 | struct font_cache_entry* p = data; | 502 | struct font_cache_entry* p = data; |
503 | struct font* pf = &font_ui; | ||
504 | unsigned short ch; | ||
496 | unsigned char tmp[2]; | 505 | unsigned char tmp[2]; |
497 | 506 | ||
498 | if (p->_char_code != 0xffff && glyph_file >= 0) { | 507 | ch = p->_char_code + pf->firstchar; |
499 | tmp[0] = p->_char_code >> 8; | 508 | |
500 | tmp[1] = p->_char_code & 0xff; | 509 | if (ch != 0xffff && glyph_file >= 0) { |
510 | tmp[0] = ch >> 8; | ||
511 | tmp[1] = ch & 0xff; | ||
501 | if (write(glyph_file, tmp, 2) != 2) { | 512 | if (write(glyph_file, tmp, 2) != 2) { |
502 | close(glyph_file); | 513 | close(glyph_file); |
503 | glyph_file = -1; | 514 | glyph_file = -1; |
@@ -545,8 +556,8 @@ void glyph_cache_load(void) | |||
545 | close(fd); | 556 | close(fd); |
546 | } else { | 557 | } else { |
547 | /* load latin1 chars into cache */ | 558 | /* load latin1 chars into cache */ |
548 | ch = 255 - pf->firstchar; | 559 | ch = 256; |
549 | while (ch--) | 560 | while (ch-- > 32) |
550 | font_get_bits(pf, ch); | 561 | font_get_bits(pf, ch); |
551 | } | 562 | } |
552 | } | 563 | } |