From 8c87d45a1fe88a45a82edd128770f3b1367df033 Mon Sep 17 00:00:00 2001 From: Jean Do Date: Fri, 18 Oct 2024 07:49:37 -0400 Subject: [PATCH] font support for pr_464 (ja-JP) --- firmware/MaixPy | 2 +- firmware/font/bdftokff.py | 50 +++++++++++++++++++-------------------- firmware/font/hextokff.py | 10 ++++---- 3 files changed, 31 insertions(+), 31 deletions(-) diff --git a/firmware/MaixPy b/firmware/MaixPy index b8bd18a2..1efd97ea 160000 --- a/firmware/MaixPy +++ b/firmware/MaixPy @@ -1 +1 @@ -Subproject commit b8bd18a2bb4bda95ea984e8c8c1901597d351c8b +Subproject commit 1efd97eacb455c233c377d0bea1b63de3d32ad05 diff --git a/firmware/font/bdftokff.py b/firmware/font/bdftokff.py index eba13e06..b2b96463 100644 --- a/firmware/font/bdftokff.py +++ b/firmware/font/bdftokff.py @@ -31,9 +31,9 @@ FONT14 = "ter-u14n" FONT16 = "ter-u16n" FONT24 = "ter-u24b" -ASIA14 = "FusionPixel-14" -ASIA16 = "unifont-16" -ASIA24 = "NotoSansCJK-24" +WIDE14 = "FusionPixel-14" +WIDE16 = "unifont-16" +WIDE24 = "NotoSansCJK-24" def open_bdf_save_kff(filename, width, height, replace): @@ -44,12 +44,12 @@ def open_bdf_save_kff(filename, width, height, replace): filename_kff = "bit_dock_yahboom" elif filename == FONT24: filename_kff = "amigo" - elif filename == ASIA14: - filename_kff = "m5stickv_asia" - elif filename == ASIA16: - filename_kff = "bit_dock_yahboom_asia" - elif filename == ASIA24: - filename_kff = "amigo_asia" + elif filename == WIDE14: + filename_kff = "m5stickv_wide" + elif filename == WIDE16: + filename_kff = "bit_dock_yahboom_wide" + elif filename == WIDE24: + filename_kff = "amigo_wide" # Create hexfile based on bdf font_hex = "\n".join(bdftohex.bdftohex(filename + ".bdf")) + "\n" @@ -73,7 +73,7 @@ def open_bdf_save_kff(filename, width, height, replace): # in order to replace the contents of the unicode[] variable # in the font.c wide_glyphs = None - if filename in (ASIA14, ASIA16, ASIA24): + if filename in (WIDE14, WIDE16, WIDE24): wide_glyphs = ["ko-KR", "zh-CN", "ja-JP"] font_kff = hextokff.hextokff(filename + ".hex", width, height, wide_glyphs) with open(filename_kff + ".kff", "w", encoding="utf-8", newline="\n") as save_file: @@ -95,14 +95,14 @@ def save_new_fontc(font_name, overwrite=False): device_name = "dock" elif font_name == FONT24: device_name = filename_kff = "amigo" - elif font_name == ASIA14: - filename_kff = "m5stickv_asia" - elif font_name == ASIA16: - filename_kff = "bit_dock_yahboom_asia" + elif font_name == WIDE14: + filename_kff = "m5stickv_wide" + elif font_name == WIDE16: + filename_kff = "bit_dock_yahboom_wide" device_name = "dock" - elif font_name == ASIA24: + elif font_name == WIDE24: device_name = "amigo" - filename_kff = "amigo_asia" + filename_kff = "amigo_wide" maixpy_path_start = "../MaixPy/projects/maixpy_" maixpy_path_end = ( @@ -112,7 +112,7 @@ def save_new_fontc(font_name, overwrite=False): with open(filename_kff + ".kff", "r", encoding="utf-8") as read_file: content_kff = read_file.read() - if font_name in (ASIA14, ASIA16, ASIA24): + if font_name in (WIDE14, WIDE16, WIDE24): re_escape_str = "static uint8_t unicode_wide[] = {\n" content_kff = re_escape_str + content_kff + "\n};" else: @@ -134,7 +134,7 @@ def save_new_fontc(font_name, overwrite=False): save_file.write(unicode_str) # Also replace for bit and yahboom - if font_name in (FONT16, ASIA16): + if font_name in (FONT16, WIDE16): filename = maixpy_path_start + "bit" + maixpy_path_end with open(filename, "w", encoding="utf-8", newline="\n") as save_file: save_file.write(unicode_str) @@ -144,7 +144,7 @@ def save_new_fontc(font_name, overwrite=False): save_file.write(unicode_str) # Also replace for Cube - if font_name in (FONT14, ASIA14): + if font_name in (FONT14, WIDE14): filename = maixpy_path_start + "cube" + maixpy_path_end with open(filename, "w", encoding="utf-8", newline="\n") as save_file: save_file.write(unicode_str) @@ -167,14 +167,14 @@ def save_new_fontc(font_name, overwrite=False): open_bdf_save_kff(FONT14, 8, 14, replace) open_bdf_save_kff(FONT16, 8, 16, replace) open_bdf_save_kff(FONT24, 12, 24, replace) - open_bdf_save_kff(ASIA14, 14, 14, replace) - open_bdf_save_kff(ASIA16, 16, 16, replace) - open_bdf_save_kff(ASIA24, 24, 24, replace) + open_bdf_save_kff(WIDE14, 14, 14, replace) + open_bdf_save_kff(WIDE16, 16, 16, replace) + open_bdf_save_kff(WIDE24, 24, 24, replace) # generate new font.c files (delete kff files) save_new_fontc(FONT14, replace) save_new_fontc(FONT16, replace) save_new_fontc(FONT24, replace) - save_new_fontc(ASIA14, replace) - save_new_fontc(ASIA16, replace) - save_new_fontc(ASIA24, replace) + save_new_fontc(WIDE14, replace) + save_new_fontc(WIDE16, replace) + save_new_fontc(WIDE24, replace) diff --git a/firmware/font/hextokff.py b/firmware/font/hextokff.py index 9cf1f67f..0c2b287e 100644 --- a/firmware/font/hextokff.py +++ b/firmware/font/hextokff.py @@ -36,14 +36,14 @@ ] TRANSLATIONS_DIR = "../../i18n/translations" -JAPANESE_CODEPOINT_MIN = 0x3000 +JAPANESE_CODEPOINT_MIN = 0x3000 # defined as WIDEFONT_CODEPOINT_MIN in MaixPy JAPANESE_CODEPOINT_MAX = 0x30FF CHINESE_CODEPOINT_MIN = 0x4E00 CHINESE_CODEPOINT_MAX = 0x9FFF KOREAN_CODEPOINT_MIN = 0xAC00 KOREAN_CODEPOINT_MAX = 0xD7A3 -FWRANDHWK_CODEPOINT_MIN = 0xFF00 # full width roman and half width katakana -FWRANDHWK_CODEPOINT_MAX = 0xFFEF +FULLHALFWIDTH_CODEPOINT_MIN = 0xFF00 +FULLHALFWIDTH_CODEPOINT_MAX = 0xFFEF # defined as WIDEFONT_CODEPOINT_MAX in MaixPy def hextokff(filename=None, width=None, height=None, wide_glyphs=None): @@ -80,9 +80,9 @@ def hextokff(filename=None, width=None, height=None, wide_glyphs=None): JAPANESE_CODEPOINT_MIN <= ord(char) <= JAPANESE_CODEPOINT_MAX or CHINESE_CODEPOINT_MIN <= ord(char) <= CHINESE_CODEPOINT_MAX or KOREAN_CODEPOINT_MIN <= ord(char) <= KOREAN_CODEPOINT_MAX - or FWRANDHWK_CODEPOINT_MIN + or FULLHALFWIDTH_CODEPOINT_MIN <= ord(char) - <= FWRANDHWK_CODEPOINT_MAX + <= FULLHALFWIDTH_CODEPOINT_MAX ): # only include if wide_glyphs required by this locale if wide_glyphs and current_translation in wide_glyphs: