Check boundaries on characters / fonts

This commit is contained in:
Raphael Coeffic
2021-05-08 08:37:53 +02:00
parent 5403ab4b00
commit 1964d2ae8c
2 changed files with 2 additions and 1 deletions
+1 -1
View File
@@ -856,7 +856,7 @@ coord_t BitmapBuffer::drawSizedText(coord_t x, coord_t y, const char * s, uint8_
uint8_t width = drawChar(x, y, font, fontspecs, c, flags);
INCREMENT_POS(width + CHAR_SPACING);
}
else if ((c >= 0x20) && (c < CJK_FIRST_LETTER_INDEX + 0x20)) {
else if ((c >= 0x20) && (c < fontCharactersTable[FONT_INDEX(flags)] + 0x20)) {
uint8_t width = drawChar(x, y, font, fontspecs, getMappedChar(c), flags);
if ((flags & SPACING_NUMBERS_CONST) && c >= '0' && c <= '9')
INCREMENT_POS(getCharWidth('9', fontspecs) + CHAR_SPACING);
@@ -22,6 +22,7 @@
#include <inttypes.h>
#include "libopenui_config.h"
extern const uint16_t fontCharactersTable[FONTS_COUNT];
extern const uint16_t * const fontspecsTable[FONTS_COUNT];
extern const uint8_t * fontsTable[FONTS_COUNT];