Characters / fonts boundary checks
This commit is contained in:
@@ -122,8 +122,20 @@ const unsigned char font_xxl[] = {
|
||||
const uint16_t * const fontspecsTable[FONTS_COUNT] = { font_std_en_specs };
|
||||
const uint8_t * fontsTable[FONTS_COUNT] = { font_std_en };
|
||||
#else
|
||||
const uint16_t * const fontspecsTable[FONTS_COUNT] = { font_std_specs, font_bold_specs, font_xxs_specs, font_xs_specs, font_l_specs, font_xl_specs, font_xxl_specs };
|
||||
const uint8_t * fontsTable[FONTS_COUNT] = { font_std, font_bold, font_xxs, font_xs, font_l, font_xl, font_xxl };
|
||||
|
||||
// -2 for: overall length and last boundary
|
||||
const uint16_t fontCharactersTable[FONTS_COUNT] = {
|
||||
sizeof(font_std_specs)/2-2, sizeof(font_bold_specs)/2-2, sizeof(font_xxs_specs)/2-2,
|
||||
sizeof(font_xs_specs)/2-2, sizeof(font_l_specs)/2-2, sizeof(font_xl_specs)/2-2,
|
||||
sizeof(font_xxl_specs)/2-2
|
||||
};
|
||||
const uint16_t *const fontspecsTable[FONTS_COUNT] = {
|
||||
font_std_specs, font_bold_specs, font_xxs_specs, font_xs_specs,
|
||||
font_l_specs, font_xl_specs, font_xxl_specs
|
||||
};
|
||||
const uint8_t *fontsTable[FONTS_COUNT] = {
|
||||
font_std, font_bold, font_xxs, font_xs, font_l, font_xl, font_xxl
|
||||
};
|
||||
#endif
|
||||
|
||||
uint8_t * decompressFont(const uint8_t * font)
|
||||
|
||||
@@ -66,9 +66,12 @@ int getTextWidth(const char * s, int len, LcdFlags flags)
|
||||
c += CJK_FIRST_LETTER_INDEX;
|
||||
result += getFontPatternWidth(specs, c) + 1;
|
||||
}
|
||||
else if ((c >= 0x20) && (c < CJK_FIRST_LETTER_INDEX + 0x20)) { // debug
|
||||
else if ((c >= 0x20) && (c < fontCharactersTable[FONT_INDEX(flags)] + 0x20)) { // debug
|
||||
result += getCharWidth(c, specs);
|
||||
}
|
||||
else {
|
||||
TRACE("char out-of bound: 0x%X", c);
|
||||
}
|
||||
|
||||
++s;
|
||||
}
|
||||
|
||||
Vendored
+1
-1
Submodule radio/src/thirdparty/libopenui updated: 7c2c8512b3...a7c793cc72
Reference in New Issue
Block a user