feat(qtmaterialsymbols): restore regenerate_mapping function

Signed-off-by: Philippe Leprince <philippe@ynput.io>
This commit is contained in:
Philippe Leprince 2025-10-03 11:12:34 +02:00
parent 0bdfc43457
commit a07a01c324

View file

@ -14,3 +14,23 @@ def get_mapping_filepath(
font_name: Optional[str] = "MaterialSymbolsOutlined"
) -> str:
return os.path.join(CURRENT_DIR, f"{font_name}.json")
def regenerate_mapping():
"""Regenerate the MaterialSymbolsOutlined.json file, assuming
MaterialSymbolsOutlined.codepoints and the TrueType font file have been
updated to support the new symbols.
"""
import json
jfile = get_mapping_filepath()
cpfile = jfile.replace(".json", ".codepoints")
with open(cpfile, "r") as cpf:
codepoints = cpf.read()
mapping = {}
for cp in codepoints.splitlines():
name, code = cp.split()
mapping[name] = int(f"0x{code}", 16)
with open(jfile, "w") as jf:
json.dump(mapping, jf, indent=4)