From ec94724b1e4ebd37bd1134ad8d4b9e09b1e8f276 Mon Sep 17 00:00:00 2001 From: Lyuwen Fu Date: Sun, 13 Feb 2022 12:12:37 +0800 Subject: [PATCH] added a script to generate .fontcustom-manifest.json from icons.yml automatically --- src/icons/.fontcustom-manifest.json | 16 +++---- src/icons/fontcustom-manifest-template.json | 49 ++++++++++++++++++++ src/icons/prepare_fontcustom-manifest.py | 21 +++++++++ src/icons/svg/{unslpash.svg => unsplash.svg} | 0 4 files changed, 78 insertions(+), 8 deletions(-) create mode 100644 src/icons/fontcustom-manifest-template.json create mode 100644 src/icons/prepare_fontcustom-manifest.py rename src/icons/svg/{unslpash.svg => unsplash.svg} (100%) diff --git a/src/icons/.fontcustom-manifest.json b/src/icons/.fontcustom-manifest.json index 07423dc3e..532c8e64c 100644 --- a/src/icons/.fontcustom-manifest.json +++ b/src/icons/.fontcustom-manifest.json @@ -1,7 +1,7 @@ { "checksum": { - "previous": "77be5ba395262597be8705aeb118a44ec323eab3250929fbe080c1082b8423d5", - "current": "77be5ba395262597be8705aeb118a44ec323eab3250929fbe080c1082b8423d5" + "previous": "0a5cfbcc5436ea854eb765f3a613bd2bfa7e06ec419c31ef81c337987d577e9f", + "current": "0a5cfbcc5436ea854eb765f3a613bd2bfa7e06ec419c31ef81c337987d577e9f" }, "fonts": [ "forkawesome/forkawesome.ttf", @@ -296,11 +296,11 @@ "source": "svg/behance-square.svg" }, "bell": { - "codepoint": 61683, + "codepoint": 61602, "source": "svg/bell.svg" }, "bell-o": { - "codepoint": 61602, + "codepoint": 61683, "source": "svg/bell-o.svg" }, "bell-ringing": { @@ -308,7 +308,7 @@ "source": "svg/bell-ringing.svg" }, "bell-ringing-o": { - "codepoint": 62304, + "codepoint": 62256, "source": "svg/bell-ringing-o.svg" }, "bell-slash": { @@ -3019,9 +3019,9 @@ "codepoint": 61758, "source": "svg/unlock-alt.svg" }, - "unslpash": { + "unsplash": { "codepoint": 62245, - "source": "svg/unslpash.svg" + "source": "svg/unsplash.svg" }, "upload": { "codepoint": 61587, @@ -3294,4 +3294,4 @@ "forkawesome/forkawesome.css", "forkawesome/forkawesome-preview.html" ] -} +} \ No newline at end of file diff --git a/src/icons/fontcustom-manifest-template.json b/src/icons/fontcustom-manifest-template.json new file mode 100644 index 000000000..822973e22 --- /dev/null +++ b/src/icons/fontcustom-manifest-template.json @@ -0,0 +1,49 @@ +{ + "checksum": { + "previous": "", + "current": "" + }, + "fonts": [ + "forkawesome/forkawesome.ttf", + "forkawesome/forkawesome.svg", + "forkawesome/forkawesome.woff", + "forkawesome/forkawesome.eot", + "forkawesome/forkawesome.woff2" + ], + "glyphs": { + }, + "options": { + "autowidth": true, + "config": "fontcustom.yml", + "copyright": "The Fork Awesome font is licensed under the SIL OFL 1.1 (http://scripts.sil.org/OFL). Fork Awesome is a fork based of off Font Awesome 4.7.0 by Dave Gandy. More info on licenses at https://forkawesome.github.io", + "css3": false, + "css_selector": ".fa-{{glyph}}", + "debug": false, + "font_ascent": 1536, + "font_descent": 256, + "font_design_size": 16, + "font_em": 1792, + "font_name": "forkawesome", + "force": false, + "input": { + "templates": "svg", + "vectors": "svg" + }, + "no_hash": true, + "output": { + "css": "forkawesome", + "fonts": "forkawesome", + "preview": "forkawesome" + }, + "preprocessor_path": "", + "quiet": false, + "templates": [ + "css", + "preview" + ] + }, + "templates": [ + "forkawesome/forkawesome.css", + "forkawesome/forkawesome-preview.html" + ] +} diff --git a/src/icons/prepare_fontcustom-manifest.py b/src/icons/prepare_fontcustom-manifest.py new file mode 100644 index 000000000..82eda9dfa --- /dev/null +++ b/src/icons/prepare_fontcustom-manifest.py @@ -0,0 +1,21 @@ +import json +import yaml +import operator + +def main(): + manifest = json.load(open("fontcustom-manifest-template.json", "r")) + icons = yaml.safe_load(open("icons.yml", "r")) + + for icon in sorted(icons["icons"], key=operator.itemgetter("id")): + manifest["glyphs"][icon["id"]] ={ + "codepoint": int(icon["unicode"], base=16), + "source": "svg/{}.svg".format(icon["id"]) + } + + + json.dump(manifest, open(".fontcustom-manifest.json","w"), indent=2) + + +if __name__ == "__main__": + main() + diff --git a/src/icons/svg/unslpash.svg b/src/icons/svg/unsplash.svg similarity index 100% rename from src/icons/svg/unslpash.svg rename to src/icons/svg/unsplash.svg