1
0
forked from me/IronOS

Bugfix: Correct binning of symbols

This commit is contained in:
Ben V. Brown
2022-12-04 22:06:59 +11:00
parent cc21dac1dc
commit 2a6dd45d56

View File

@@ -168,7 +168,7 @@ def get_power_source_list() -> List[str]:
def test_is_small_font(msg: str) -> bool: def test_is_small_font(msg: str) -> bool:
return "\n" in msg return "\n" in msg and msg[0] != "\n"
def get_letter_counts(defs: dict, lang: dict, build_version: str) -> Dict: def get_letter_counts(defs: dict, lang: dict, build_version: str) -> Dict:
@@ -186,11 +186,6 @@ def get_letter_counts(defs: dict, lang: dict, build_version: str) -> Dict:
small_font_messages = [] small_font_messages = []
# iterate over all strings # iterate over all strings
obj = lang["menuOptions"]
for mod in defs["menuOptions"]:
eid = mod["id"]
msg = obj[eid]["description"]
big_font_messages.append(msg)
obj = lang["messagesWarn"] obj = lang["messagesWarn"]
for mod in defs["messagesWarn"]: for mod in defs["messagesWarn"]:
@@ -220,6 +215,13 @@ def get_letter_counts(defs: dict, lang: dict, build_version: str) -> Dict:
else: else:
big_font_messages.append(msg) big_font_messages.append(msg)
obj = lang["menuOptions"]
for mod in defs["menuOptions"]:
eid = mod["id"]
msg = obj[eid]["description"]
big_font_messages.append(msg)
obj = lang["menuGroups"] obj = lang["menuGroups"]
for mod in defs["menuGroups"]: for mod in defs["menuGroups"]:
eid = mod["id"] eid = mod["id"]
@@ -235,13 +237,15 @@ def get_letter_counts(defs: dict, lang: dict, build_version: str) -> Dict:
msg = obj[eid]["description"] msg = obj[eid]["description"]
big_font_messages.append(msg) big_font_messages.append(msg)
constants = get_constants() constants = get_constants()
for x in constants: for x in constants:
msg = x[1] if x[0].startswith("Small"):
if test_is_small_font(msg): small_font_messages.append(x[1])
small_font_messages.append(msg)
else: else:
big_font_messages.append(msg) big_font_messages.append(x[1])
small_font_messages.extend(get_debug_menu()) small_font_messages.extend(get_debug_menu())
small_font_messages.extend(get_accel_names_list()) small_font_messages.extend(get_accel_names_list())
small_font_messages.extend(get_power_source_list()) small_font_messages.extend(get_power_source_list())
@@ -322,9 +326,11 @@ def merge_letter_count_info(a: Dict, b: Dict) -> Dict:
} }
def get_cjk_glyph(sym: str) -> bytes: def get_cjk_glyph(sym: str) -> Optional[bytes]:
glyph: Glyph = cjk_font()[ord(sym)] try:
glyph: Glyph = cjk_font()[ord(sym)]
except KeyError:
return None
data = glyph.data data = glyph.data
src_left, src_bottom, src_w, src_h = glyph.get_bounding_box() src_left, src_bottom, src_w, src_h = glyph.get_bounding_box()
dst_w = 12 dst_w = 12
@@ -615,8 +621,9 @@ def convert_string_bytes(symbol_conversion_table: Dict[str, bytes], text: str) -
output_string = b"" output_string = b""
for c in text.replace("\\r", "").replace("\\n", "\n"): for c in text.replace("\\r", "").replace("\\n", "\n"):
if c not in symbol_conversion_table: if c not in symbol_conversion_table:
print(symbol_conversion_table)
logging.error(f"Missing font definition for {c}") logging.error(f"Missing font definition for {c}")
sys.exit(1) raise KeyError(f"Missing font definition for {c}")
else: else:
output_string += symbol_conversion_table[c] output_string += symbol_conversion_table[c]
return output_string return output_string
@@ -913,7 +920,6 @@ def write_languages(
"const FontSectionDataInfo FontSectionDataInfos[] = {\n" "const FontSectionDataInfo FontSectionDataInfos[] = {\n"
) )
for font, current_sym_list in sym_lists_by_font.items(): for font, current_sym_list in sym_lists_by_font.items():
print(font, current_sym_list)
if len(current_sym_list) == 0: if len(current_sym_list) == 0:
continue continue
current_sym_start = combined_sym_list.index(current_sym_list[0]) + 2 current_sym_start = combined_sym_list.index(current_sym_list[0]) + 2
@@ -1044,12 +1050,10 @@ def get_translation_common_text(
translation_common_text += "const char* DebugMenu[] = {\n" translation_common_text += "const char* DebugMenu[] = {\n"
for c in get_debug_menu(): for c in get_debug_menu():
print(c,convert_string(small_symbol_conversion_table, c))
translation_common_text += ( translation_common_text += (
f'\t "{convert_string(small_symbol_conversion_table, c)}",//"{c}" \n' f'\t "{convert_string(small_symbol_conversion_table, c)}",//"{c}" \n'
) )
translation_common_text += "};\n\n" translation_common_text += "};\n\n"
print(small_symbol_conversion_table)
# accel names # accel names
translation_common_text += "const char* AccelTypeNames[] = {\n" translation_common_text += "const char* AccelTypeNames[] = {\n"
@@ -1107,7 +1111,7 @@ def get_translation_strings_and_indices_text(
): ):
for i, byte_data in enumerate(byte_encoded_strings): for i, byte_data in enumerate(byte_encoded_strings):
if byte_data.endswith(encoded_string): if byte_data.endswith(encoded_string):
logging.info(f"Collapsing {translation_id} into index {i}") logging.info(f"Collapsing {translation_id}")
record = TranslatedStringLocation( record = TranslatedStringLocation(
i, len(byte_data) - len(encoded_string) i, len(byte_data) - len(encoded_string)
) )
@@ -1156,7 +1160,7 @@ def get_translation_strings_and_indices_text(
lang_data = lang["messagesWarn"][record["id"]] lang_data = lang["messagesWarn"][record["id"]]
# Add to translations the menu text and the description # Add to translations the menu text and the description
encode_string_and_add( encode_string_and_add(
lang_data["message"], "messagesWarn" + record["id"] + "Message",True lang_data["message"], "messagesWarn" + record["id"] + "Message"
) )
for index, record in enumerate(defs["characters"]): for index, record in enumerate(defs["characters"]):