|
| 1 | +#!/usr/bin/python3 |
| 2 | + |
| 3 | +import shutil |
| 4 | +import json |
| 5 | +from os.path import dirname, join |
| 6 | + |
| 7 | +from fontTools.ttLib import TTFont |
| 8 | + |
| 9 | +dest = join(dirname(__file__), "./theme/eos-icons.woff") |
| 10 | +shutil.copyfile( |
| 11 | + join( |
| 12 | + dirname(__file__), "./node_modules/eos-icons/dist/fonts/eos-icons.woff" |
| 13 | + ), |
| 14 | + dest, |
| 15 | +) |
| 16 | + |
| 17 | +code_points = {} |
| 18 | + |
| 19 | +with TTFont(dest, 0, ignoreDecompileErrors=True) as ttf: |
| 20 | + for x in ttf["cmap"].tables: |
| 21 | + for (code, name) in x.cmap.items(): |
| 22 | + code_points[name] = code |
| 23 | + |
| 24 | + |
| 25 | +icon_to_glyph_mapping = [ |
| 26 | + ["accounts-view-bar-icon", "account_circle"], |
| 27 | + ["callhierarchy-incoming", "call_received"], |
| 28 | + ["callhierarchy-outgoing", "call_made"], |
| 29 | + ["callstack-view-session", "bug_report"], |
| 30 | + ["comments-view-icon", "comment"], |
| 31 | + ["debug-configure", "settings_applications"], |
| 32 | + ["extensions-manage", "settings_applications"], |
| 33 | + ["settings-view-bar-icon", "settings_applications"], |
| 34 | +] |
| 35 | + |
| 36 | +eos_icons_theme = { |
| 37 | + "fonts": [ |
| 38 | + { |
| 39 | + "id": "eos-icons", |
| 40 | + "src": [ |
| 41 | + { |
| 42 | + "path": "./eos-icons.woff", |
| 43 | + "format": "woff", |
| 44 | + }, |
| 45 | + ], |
| 46 | + "weight": "normal", |
| 47 | + "style": "normal", |
| 48 | + }, |
| 49 | + ], |
| 50 | + "iconDefinitions": {}, |
| 51 | +} |
| 52 | + |
| 53 | +for (icon_name, glyph_name) in icon_to_glyph_mapping: |
| 54 | + eos_icons_theme["iconDefinitions"][icon_name] = { |
| 55 | + "fontCharacter": chr(code_points[glyph_name]), |
| 56 | + } |
| 57 | + |
| 58 | +with open( |
| 59 | + join(dirname(__file__), "theme/eos-icons-product-icon-theme.json"), "w" |
| 60 | +) as product_icon_file: |
| 61 | + product_icon_file.write(json.dumps(eos_icons_theme, indent=2)) |
0 commit comments