From a07a01c3243ad471d65984003e2eab6b9648b0d5 Mon Sep 17 00:00:00 2001 From: Philippe Leprince Date: Fri, 3 Oct 2025 11:12:34 +0200 Subject: [PATCH] feat(qtmaterialsymbols): restore regenerate_mapping function Signed-off-by: Philippe Leprince --- .../qtmaterialsymbols/resources/__init__.py | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/client/ayon_core/vendor/python/qtmaterialsymbols/resources/__init__.py b/client/ayon_core/vendor/python/qtmaterialsymbols/resources/__init__.py index 6da4c6986b..a92cb36f33 100644 --- a/client/ayon_core/vendor/python/qtmaterialsymbols/resources/__init__.py +++ b/client/ayon_core/vendor/python/qtmaterialsymbols/resources/__init__.py @@ -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)