mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 12:54:40 +01:00
feat(qtmaterialsymbols): restore regenerate_mapping function
Signed-off-by: Philippe Leprince <philippe@ynput.io>
This commit is contained in:
parent
0bdfc43457
commit
a07a01c324
1 changed files with 20 additions and 0 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue