Skip to content

Commit

Permalink
Merge pull request #494 from jdlcdl/ja-JP_simulator_support
Browse files Browse the repository at this point in the history
resolves simulator support for ja-JP
  • Loading branch information
odudex authored Dec 11, 2024
2 parents 2d94a05 + 2be4cc6 commit 4bfe2cc
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions simulator/kruxsim/mocks/lcd.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
WIDTH = BOARD_CONFIG["lcd"]["width"]
HEIGHT = BOARD_CONFIG["lcd"]["height"]

JAPANESE_CODEPOINT_MIN = 0x3000
JAPANESE_CODEPOINT_MAX = 0x30FF
CHINESE_CODEPOINT_MIN = 0x4E00
CHINESE_CODEPOINT_MAX = 0x9FFF
KOREAN_CODEPOINT_MIN = 0xAC00
Expand Down Expand Up @@ -153,7 +155,8 @@ def string_width_px(string):

for c in string:
if (
CHINESE_CODEPOINT_MIN <= ord(c) <= CHINESE_CODEPOINT_MAX
JAPANESE_CODEPOINT_MIN <= ord(c) <= JAPANESE_CODEPOINT_MAX
or CHINESE_CODEPOINT_MIN <= ord(c) <= CHINESE_CODEPOINT_MAX
or KOREAN_CODEPOINT_MIN <= ord(c) <= KOREAN_CODEPOINT_MAX
):
string_width += wide_width
Expand All @@ -165,21 +168,24 @@ def string_width_px(string):
def string_has_wide_glyph(string):
for c in string:
if (
CHINESE_CODEPOINT_MIN <= ord(c) <= CHINESE_CODEPOINT_MAX
JAPANESE_CODEPOINT_MIN <= ord(c) <= JAPANESE_CODEPOINT_MAX
or CHINESE_CODEPOINT_MIN <= ord(c) <= CHINESE_CODEPOINT_MAX
or KOREAN_CODEPOINT_MIN <= ord(c) <= KOREAN_CODEPOINT_MAX
):
return True
return False

def is_wide(c):
return (
CHINESE_CODEPOINT_MIN <= ord(c) <= CHINESE_CODEPOINT_MAX
JAPANESE_CODEPOINT_MIN <= ord(c) <= JAPANESE_CODEPOINT_MAX
or CHINESE_CODEPOINT_MIN <= ord(c) <= CHINESE_CODEPOINT_MAX
or KOREAN_CODEPOINT_MIN <= ord(c) <= KOREAN_CODEPOINT_MAX
)

def char_width(c):
if (
CHINESE_CODEPOINT_MIN <= ord(c) <= CHINESE_CODEPOINT_MAX
JAPANESE_CODEPOINT_MIN <= ord(c) <= JAPANESE_CODEPOINT_MAX
or CHINESE_CODEPOINT_MIN <= ord(c) <= CHINESE_CODEPOINT_MAX
or KOREAN_CODEPOINT_MIN <= ord(c) <= KOREAN_CODEPOINT_MAX
):
return BOARD_CONFIG["krux"]["display"]["font_wide"][0]
Expand Down

0 comments on commit 4bfe2cc

Please sign in to comment.