1+ import json
12import re
23import subprocess
34import os
@@ -25,12 +26,8 @@ def list_to_plain_string(list: list[int]) -> str:
2526 return "," .join (map (str , list ))
2627
2728
28- def extract_simplified_chinese_unicode ():
29- return list_to_plain_string (extract_unicode_points (Path (__file__ ).parent / "../../mkapp/app/language/zh_hans.ini" , re .compile (r'[\u4e00-\u9fff]' )))
30-
31-
32- def extract_spanish_unicode ():
33- return list_to_plain_string (extract_unicode_points (Path (__file__ ).parent / "../../mkapp/app/language/es_es.ini" , re .compile (r'[\u00C0-\u00FF]' )))
29+ def unicode_points_range (input_file : Path , char_pattern : re .Pattern = re .compile ('.' )) -> str :
30+ return list_to_plain_string (extract_unicode_points (input_file , char_pattern ))
3431
3532
3633def patch ():
@@ -64,15 +61,14 @@ def generate_fonts():
6461 cmd_font_lvgl_privite = " --font FontAwesome5-Solid+Brands+Regular.woff"
6562 cmd_range_lvgl_privite = " --range 61441,61448,61451,61452,61452,61453,61457,61459,61461,61465,61468,61473,61478,61479,61480,61502,61507,61512,61515,61516,61517,61521,61522,61523,61524,61543,61544,61550,61552,61553,61556,61559,61560,61561,61563,61587,61589,61636,61637,61639,61641,61664,61671,61674,61683,61724,61732,61787,61931,62016,62017,62018,62019,62020,62087,62099,62212,62189,62810,63426,63650"
6663
67- cmd_font_simplified_chinese = " --font simhei.ttf"
68- cmd_range_simplified_chinese = " --range " + \
69- extract_simplified_chinese_unicode ()
64+ cmd_languages : str = ""
7065
71- cmd_font_cyrillic = " --font Montserrat-Medium.ttf"
72- cmd_range_cyrillic = " --range 1024-1279"
66+ with open ( Path ( __file__ ). parent / "language_info.json" , 'r' ) as f :
67+ language_info = json . load ( f )
7368
74- cmd_font_spanish = " --font Montserrat-Medium.ttf"
75- cmd_range_spanish = " --range " + extract_spanish_unicode ()
69+ BASE_LANGUAGE_PATH : Path = Path (__file__ ).parent / "../../mkapp/app/language"
70+ for language in language_info :
71+ cmd_languages += " --font " + language ["font" ] + " --range " + unicode_points_range (BASE_LANGUAGE_PATH / language ["ini" ], re .compile (language ["range" ]))
7672
7773 font_size = [8 , 10 , 12 , 14 , 16 , 18 , 20 , 22 , 24 ,
7874 26 , 28 , 30 , 32 , 34 , 36 , 38 , 40 , 42 , 44 , 46 , 48 ]
@@ -88,13 +84,7 @@ def generate_fonts():
8884 command += cmd_range_default
8985 command += cmd_font_lvgl_privite
9086 command += cmd_range_lvgl_privite
91- command += cmd_font_simplified_chinese
92- command += cmd_range_simplified_chinese
93- command += cmd_font_cyrillic
94- command += cmd_range_cyrillic
95- command += cmd_font_spanish
96- command += cmd_range_spanish
97-
87+ command += cmd_languages
9888
9989 command += cmd_format
10090 command += cmd_output + str (s ) + ".c"
0 commit comments