Fix wrong Chinese characters being displayed (#1257)
* Fixed wrong index calculation. * Fixed font generation, indexing will goes wrong when no extra chars bitmap is present. * Image width exceeded 16384 will cause trouble in CJK. * Include libopenui update Co-authored-by: Peter Feerick <peter.feerick@gmail.com>
This commit is contained in:
co-authored by
Peter Feerick
parent
85bd9d16ea
commit
843d1be868
@@ -32,7 +32,11 @@ add_truetype_font_target(17 17 ${subset} none "${FONT_ARGS}")
|
|||||||
add_truetype_font_target(17en 17 en none "${FONT_ARGS}")
|
add_truetype_font_target(17en 17 en none "${FONT_ARGS}")
|
||||||
add_truetype_font_target(bold17 17 ${subset} bold "${FONT_ARGS}")
|
add_truetype_font_target(bold17 17 ${subset} bold "${FONT_ARGS}")
|
||||||
add_truetype_font_target(24 24 ${subset} none "${FONT_ARGS}")
|
add_truetype_font_target(24 24 ${subset} none "${FONT_ARGS}")
|
||||||
add_truetype_font_target(32 32 ${subset} bold "${FONT_ARGS}")
|
if( (${subset} STREQUAL "cn") OR (${subset} STREQUAL "tw"))
|
||||||
|
add_truetype_font_target(32 30 ${subset} bold "${FONT_ARGS}")
|
||||||
|
else()
|
||||||
|
add_truetype_font_target(32 32 ${subset} bold "${FONT_ARGS}")
|
||||||
|
endif()
|
||||||
add_truetype_font_target(64 64 en bold "${FONT_ARGS}")
|
add_truetype_font_target(64 64 en bold "${FONT_ARGS}")
|
||||||
|
|
||||||
add_custom_target(truetype_fonts DEPENDS ${truetype_fonts_targets})
|
add_custom_target(truetype_fonts DEPENDS ${truetype_fonts_targets})
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ int getTextWidth(const char * s, int len, LcdFlags flags)
|
|||||||
else if (c >= 0xFE) { // CJK marker
|
else if (c >= 0xFE) { // CJK marker
|
||||||
s++;
|
s++;
|
||||||
c = uint8_t(*s) + ((c & 0x01) << 8) - 1;
|
c = uint8_t(*s) + ((c & 0x01) << 8) - 1;
|
||||||
if (c >= 0x101)
|
if (c >= 0x100)
|
||||||
c -= 1;
|
c -= 1;
|
||||||
c += CJK_FIRST_LETTER_INDEX;
|
c += CJK_FIRST_LETTER_INDEX;
|
||||||
result += getFontPatternWidth(specs, c) + 1;
|
result += getFontPatternWidth(specs, c) + 1;
|
||||||
|
|||||||
Vendored
+1
-1
Submodule radio/src/thirdparty/libopenui updated: ad4234ad5d...ea70d9fcd0
+15
-10
@@ -18,6 +18,7 @@ class FontBitmap:
|
|||||||
self.background = background
|
self.background = background
|
||||||
self.font = self.load_font(font_name)
|
self.font = self.load_font(font_name)
|
||||||
self.extra_bitmap = self.load_extra_bitmap()
|
self.extra_bitmap = self.load_extra_bitmap()
|
||||||
|
self.extra_bitmap_added = False
|
||||||
self.extra_bitmap_width = EXTRA_BITMAP_MAX_WIDTH
|
self.extra_bitmap_width = EXTRA_BITMAP_MAX_WIDTH
|
||||||
if self.extra_bitmap is not None:
|
if self.extra_bitmap is not None:
|
||||||
self.extra_bitmap_width = self.extra_bitmap.width
|
self.extra_bitmap_width = self.extra_bitmap.width
|
||||||
@@ -80,22 +81,26 @@ class FontBitmap:
|
|||||||
width = 0
|
width = 0
|
||||||
for c in self.chars:
|
for c in self.chars:
|
||||||
if c in extra_chars:
|
if c in extra_chars:
|
||||||
if self.extra_bitmap:
|
if not self.extra_bitmap_added:
|
||||||
|
|
||||||
# append same width for non-existing characters
|
# append same width for non-existing characters
|
||||||
for i in range(128 - 32 - len(standard_chars)):
|
for i in range(128 - 32 - len(standard_chars)):
|
||||||
coords.append(width)
|
coords.append(width)
|
||||||
|
|
||||||
# copy extra_bitmap at once
|
if self.extra_bitmap:
|
||||||
image.paste(self.extra_bitmap, (width, offset_y))
|
|
||||||
|
|
||||||
# append width for extra_bitmap symbols
|
# copy extra_bitmap at once
|
||||||
for coord in [14, 14, 12, 12, 13, 13, 13, 13, 13] + [15] * 12:
|
image.paste(self.extra_bitmap, (width, offset_y))
|
||||||
coords.append(width)
|
|
||||||
width += coord
|
|
||||||
|
|
||||||
# once inserted, now remove it
|
# append width for extra_bitmap symbols
|
||||||
self.extra_bitmap = None
|
for coord in [14, 14, 12, 12, 13, 13, 13, 13, 13] + [15] * 12:
|
||||||
|
coords.append(width)
|
||||||
|
width += coord
|
||||||
|
else:
|
||||||
|
for coord in range(21):
|
||||||
|
coords.append(width)
|
||||||
|
|
||||||
|
# once inserted, disable insert again
|
||||||
|
self.extra_bitmap_added = True
|
||||||
|
|
||||||
# skip
|
# skip
|
||||||
continue
|
continue
|
||||||
|
|||||||
Reference in New Issue
Block a user