Skip to content

Commit e2b613d

Browse files
imnasnainaecclaude
andauthored
Bump mlp; Update font script, fonts (#4308)
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 9ec1ffb commit e2b613d

6 files changed

Lines changed: 121 additions & 27 deletions

File tree

docs/user_guide/assets/licenses/frontend_licenses.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3698,11 +3698,11 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
36983698
SOFTWARE.
36993699

37003700

3701-
mui-language-picker 2.6.1
3701+
mui-language-picker 2.7.5
37023702
MIT
37033703
MIT License
37043704

3705-
Copyright (c) 2020-2022 SIL LSDev
3705+
Copyright (c) 2020-2026 SIL LSDev
37063706

37073707
Permission is hereby granted, free of charge, to any person obtaining a copy
37083708
of this software and associated documentation files (the "Software"), to deal

maintenance/scripts/get_fonts.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,12 @@ def check_font_info(font_info: dict[str, Any]) -> bool:
113113
logging.debug(f"{family}: No file list")
114114
return False
115115

116+
file_name = get_font_default(font_info["defaults"])
117+
file_info = font_info["files"].get(file_name, {})
118+
if "flourl" not in file_info and "url" not in file_info:
119+
logging.debug(f"{family}: Default file has no download URL")
120+
return False
121+
116122
return True
117123

118124

@@ -149,7 +155,7 @@ def fetch_fonts_for_scripts(scripts: List[str]) -> List[str]:
149155
scripts = list({script.capitalize() for script in scripts})
150156

151157
# Always have the Mui-Language-Picker default/safe fonts.
152-
fonts = ["Annapurna SIL", "Charis SIL", "Noto Sans TC", "Scheherazade New"]
158+
fonts = ["Annapurna SIL", "Charis", "Noto Sans TC", "Scheherazade New"]
153159

154160
logging.debug(f"Downloading script font table from {url_script_font_table}")
155161
req = requests.get(url_script_font_table)
@@ -245,9 +251,10 @@ def main() -> None:
245251
font_id: str = font.replace(" ", "").lower()
246252

247253
# Get font family info from font families info, using fallback font if necessary.
254+
family: str = ""
248255
while font_id != "" and font_id in families.keys():
249256
font_info = families[font_id]
250-
family: str = font_info["family"]
257+
family = font_info["family"]
251258
source_is_google = "source" in font_info.keys() and font_info["source"] == "Google"
252259
get_from_google = source_is_google and not is_for_offline
253260
if check_font_info(font_info) or get_from_google:
@@ -319,7 +326,7 @@ def main() -> None:
319326

320327
# Finish the css info for this font and write to file.
321328
css_lines.append("}\n")
322-
css_file_path = args.output / f"{font}.css"
329+
css_file_path = args.output / f"{font.replace(' ', '')}.css"
323330
logging.debug(f"Writing {css_file_path}")
324331
with open(css_file_path, "w") as css_file:
325332
css_file.writelines(css_lines)

maintenance/scripts/mui_language_picker_fonts.txt

Lines changed: 78 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,43 @@
1+
Aboriginal Sans
12
Abyssinica SIL
3+
Akatab
4+
Alkalami
5+
Andika
26
Annapurna SIL
3-
BJCree UNI
7+
Annapurna SIL Nepal
8+
Awami Nastaliq
9+
BJCree
410
Badami
5-
Charis SIL
11+
Charis
12+
Charis SIL Compact
613
Dai Banna SIL
714
Dukor
15+
Eeyek
816
Ezra SIL
9-
Gentium Plus
17+
Galatia SIL
18+
Gentium
19+
Gentium Book
20+
Harmattan
21+
Idiqlat
1022
Japa Sans Oriya
23+
Jomolhari
1124
Kanchenjunga
1225
Kay Pho Du
26+
Khmer Busra
1327
Khmer Mondulkiri
28+
Lateef
1429
Lisu Bosa
1530
Mingzat
1631
Namdhinggo
1732
Narnoor
33+
Nokyung
34+
Noto Naskh Arabic
35+
Noto Nastaliq Urdu
36+
Noto Sans
37+
Noto Sans Adlam
1838
Noto Sans Anatolian Hieroglyphs
39+
Noto Sans Arabic
40+
Noto Sans Armenian
1941
Noto Sans Avestan
2042
Noto Sans Balinese
2143
Noto Sans Bamum
@@ -26,6 +48,7 @@ Noto Sans Bhaiksuki
2648
Noto Sans Brahmi
2749
Noto Sans Buginese
2850
Noto Sans Buhid
51+
Noto Sans Canadian Aboriginal
2952
Noto Sans Carian
3053
Noto Sans Caucasian Albanian
3154
Noto Sans Chakma
@@ -36,10 +59,12 @@ Noto Sans Coptic
3659
Noto Sans Cuneiform
3760
Noto Sans Cypriot
3861
Noto Sans Deseret
62+
Noto Sans Devanagari
3963
Noto Sans Duployan
4064
Noto Sans Egyptian Hieroglyphs
4165
Noto Sans Elbasan
4266
Noto Sans Elymaic
67+
Noto Sans Ethiopic
4368
Noto Sans Georgian
4469
Noto Sans Glagolitic
4570
Noto Sans Gothic
@@ -49,21 +74,30 @@ Noto Sans Gurmukhi
4974
Noto Sans Hanifi Rohingya
5075
Noto Sans Hanunoo
5176
Noto Sans Hatran
77+
Noto Sans Hebrew
5278
Noto Sans Imperial Aramaic
5379
Noto Sans Inscriptional Pahlavi
5480
Noto Sans Inscriptional Parthian
5581
Noto Sans JP
5682
Noto Sans Javanese
5783
Noto Sans KR
5884
Noto Sans Kaithi
85+
Noto Sans Kannada
86+
Noto Sans Kayah Li
5987
Noto Sans Kharoshthi
88+
Noto Sans Khmer
6089
Noto Sans Khojki
6190
Noto Sans Khudawadi
91+
Noto Sans Lao
92+
Noto Sans Lepcha
93+
Noto Sans Limbu
6294
Noto Sans Linear A
6395
Noto Sans Linear B
96+
Noto Sans Lisu
6497
Noto Sans Lycian
6598
Noto Sans Lydian
6699
Noto Sans Mahajani
100+
Noto Sans Malayalam
67101
Noto Sans Mandaic
68102
Noto Sans Manichaean
69103
Noto Sans Marchen
@@ -72,14 +106,17 @@ Noto Sans Medefaidrin
72106
Noto Sans Meetei Mayek
73107
Noto Sans Mende Kikakui
74108
Noto Sans Meroitic
109+
Noto Sans Miao
75110
Noto Sans Modi
76111
Noto Sans Mongolian
77112
Noto Sans Mro
78113
Noto Sans Multani
114+
Noto Sans Myanmar
79115
Noto Sans NKo
80116
Noto Sans Nabataean
81117
Noto Sans Nag Mundari
82118
Noto Sans Nandinagari
119+
Noto Sans New Tai Lue
83120
Noto Sans Newa
84121
Noto Sans Ogham
85122
Noto Sans Ol Chiki
@@ -91,6 +128,7 @@ Noto Sans Old Persian
91128
Noto Sans Old Sogdian
92129
Noto Sans Old South Arabian
93130
Noto Sans Old Turkic
131+
Noto Sans Oriya
94132
Noto Sans Osage
95133
Noto Sans Osmanya
96134
Noto Sans Pahawh Hmong
@@ -107,49 +145,83 @@ Noto Sans Saurashtra
107145
Noto Sans Sharada
108146
Noto Sans Shavian
109147
Noto Sans Siddham
110-
Noto Sans SignWriting
148+
Noto Sans Sign Writing
111149
Noto Sans Sinhala
112150
Noto Sans Sogdian
113151
Noto Sans Sora Sompeng
114152
Noto Sans Soyombo
115153
Noto Sans Sundanese
154+
Noto Sans Syloti Nagri
155+
Noto Sans Symbols2
116156
Noto Sans Syriac
157+
Noto Sans Syriac Eastern
117158
Noto Sans TC
118159
Noto Sans Tagalog
160+
Noto Sans Tagbanwa
119161
Noto Sans Tai Le
120162
Noto Sans Tai Tham
163+
Noto Sans Tai Viet
121164
Noto Sans Takri
122165
Noto Sans Tamil
123166
Noto Sans Tangsa
167+
Noto Sans Telugu
124168
Noto Sans Thaana
125169
Noto Sans Thai
126170
Noto Sans Tifinagh
127171
Noto Sans Tirhuta
128172
Noto Sans Ugaritic
129-
Noto Sans Vithkuqi
173+
Noto Sans Vai
130174
Noto Sans Wancho
131175
Noto Sans Warang Citi
176+
Noto Sans Yi
132177
Noto Sans Zanabazar Square
178+
Noto Serif
133179
Noto Serif Ahom
134180
Noto Serif Armenian
181+
Noto Serif Bengali
182+
Noto Serif Devanagari
135183
Noto Serif Dogra
184+
Noto Serif Ethiopic
185+
Noto Serif Georgian
186+
Noto Serif Gujarati
187+
Noto Serif Gurmukhi
188+
Noto Serif Hebrew
136189
Noto Serif JP
137190
Noto Serif KR
191+
Noto Serif Kannada
138192
Noto Serif Khitan Small Script
193+
Noto Serif Khmer
194+
Noto Serif Lao
139195
Noto Serif Makasar
140196
Noto Serif Malayalam
141-
Noto Serif NP Hmong
197+
Noto Serif Myanmar
198+
Noto Serif NPHmong
142199
Noto Serif Old Uyghur
143200
Noto Serif SC
201+
Noto Serif Sinhala
202+
Noto Serif TC
203+
Noto Serif Tamil
144204
Noto Serif Tangut
145205
Noto Serif Telugu
206+
Noto Serif Thai
146207
Noto Serif Tibetan
147208
Noto Serif Toto
148209
Noto Serif Yezidi
210+
Noto Traditional Nushu
149211
Nuosu SIL
150212
Padauk
213+
Payap Lanna
214+
Ramsina
215+
Ruwudu
216+
SEI Sunuwar
151217
Sapushan
218+
Sarabun
152219
Saysettha
220+
Saysettha MX
153221
Scheherazade New
222+
Shimenkan
223+
Sophia Nubian
154224
Surma
225+
Tagmukay
155226
Tai Heritage Pro
227+
ThiruValluvar

package-lock.json

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
"levenshtein-search": "~0.1.2",
6565
"material-react-table": "~3.2.1",
6666
"motion": "~12.38.0",
67-
"mui-language-picker": "~2.6.1",
67+
"mui-language-picker": "~2.7.5",
6868
"notistack": "~3.0.2",
6969
"nspell": "~2.1.5",
7070
"punycode": "~2.3.1",

scripts/get_fonts_dev.py

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
#!/usr/bin/env python
22

33
"""
4-
Runs maintenance/scripts/get_fonts.py with dev arguments for -f and -o.
4+
Runs maintenance/scripts/get_fonts.py with dev arguments for -u and -o.
55
Run this script with -U/--update whenever the mui-language-picker version is updated.
66
"""
77

88
import argparse
9+
import json
10+
import logging
911
from pathlib import Path
1012
import platform
1113
import re
@@ -15,9 +17,9 @@
1517
dev_output_dir = project_dir / "public" / "fonts"
1618
maintenance_scripts_dir = project_dir / "maintenance" / "scripts"
1719
mlp_font_list = maintenance_scripts_dir / "mui_language_picker_fonts.txt"
18-
mlp_font_families = (
19-
project_dir / "node_modules" / "mui-language-picker" / "dist" / "data" / "scriptFontIndex.js"
20-
)
20+
mlp_data_dir = project_dir / "node_modules" / "mui-language-picker" / "dist" / "data"
21+
mlp_font_families = mlp_data_dir / "scriptFontIndex.js"
22+
mlp_families_json = mlp_data_dir / "families.json"
2123

2224

2325
def parse_args() -> argparse.Namespace:
@@ -72,12 +74,25 @@ def main() -> None:
7274
args = parse_args()
7375

7476
if args.update:
75-
# Font families are in the file as: \"family\":\"Font Family Name\"
76-
family_pattern = re.compile(r'\\"family\\"\:\\"([^\\]+)\\"')
77-
with open(mlp_font_families, "r") as families_file:
78-
matches = re.findall(family_pattern, families_file.read())
79-
font_lines = [match + "\n" for match in set(matches)]
77+
with open(mlp_font_families, "r") as f:
78+
content = f.read()
79+
array_match = re.search(r"exports\.default = (\[.*?\]);", content, re.DOTALL)
80+
if not array_match:
81+
raise ValueError(f"Could not parse font index from {mlp_font_families}")
82+
83+
data = json.loads(array_match.group(1))
84+
all_slugs = {slug for entry in data if len(entry) >= 2 for slug in entry[1]}
85+
86+
with open(mlp_families_json, "r") as f:
87+
families = json.load(f)
88+
font_lines = []
89+
for slug in all_slugs:
90+
if slug in families:
91+
font_lines.append(families[slug]["family"] + "\n")
92+
else:
93+
logging.warning("Slug '%s' not found in families.json, skipping", slug)
8094
font_lines.sort()
95+
8196
with open(mlp_font_list, "w") as fonts_file:
8297
fonts_file.writelines(font_lines)
8398

@@ -92,7 +107,7 @@ def main() -> None:
92107
if args.clean:
93108
command.append("-c")
94109
if args.local_font_url:
95-
command.append("-f")
110+
command.append("-u")
96111
command.append(args.local_font_url)
97112
if args.langs:
98113
command.append("-l")

0 commit comments

Comments
 (0)