From ea83660ec7d003c5f632af52aca0c4d42d4bb67a Mon Sep 17 00:00:00 2001 From: Zentropivity Date: Fri, 27 Sep 2024 09:36:33 +0200 Subject: [PATCH] This is a start. --- .gitignore | 2 ++ .gitmodules | 9 +++++++++ README.md | 29 +++++++++++++++++++++++++++++ build_ttf.nu | 34 ++++++++++++++++++++++++++++++++++ glyphmap_generator.nu | 18 ++++++++++++++++++ install.nu | 4 ++++ mutant_standard | 1 + nanoemoji | 1 + orxporter | 1 + 9 files changed, 99 insertions(+) create mode 100644 .gitignore create mode 100644 .gitmodules create mode 100644 README.md create mode 100755 build_ttf.nu create mode 100755 glyphmap_generator.nu create mode 100755 install.nu create mode 160000 mutant_standard create mode 160000 nanoemoji create mode 160000 orxporter diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0e3ba83 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +venv +out diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..fb3200c --- /dev/null +++ b/.gitmodules @@ -0,0 +1,9 @@ +[submodule "mutant_standard"] + path = mutant_standard + url = https://github.com/mutantstandard/build.git +[submodule "orxporter"] + path = orxporter + url = https://github.com/mutantstandard/orxporter.git +[submodule "nanoemoji"] + path = nanoemoji + url = https://github.com/googlefonts/nanoemoji.git diff --git a/README.md b/README.md new file mode 100644 index 0000000..fbecdfc --- /dev/null +++ b/README.md @@ -0,0 +1,29 @@ +# Build Mutant Standard as TTF font + +Why? Because its a great emoji font! I want to see them all over my desktop. + +## How? + +First you need to make sure the required tools are installed: + +- `nushell` (probably could have made it without, but I like to script using it `¯\_(ツ)_/¯`) +- `python` (and its virtualenv/venv and pip) +- `git` of course + +0. Make sure you have the submodules. Either clone this repo with `--recursive` or do `git submodule update --init` +1. Create a python virtual environment and activate it, like: `python -m venv venv` then source right activation file for your shell +2. Run `build_ttf.nu` + this produces the font file in `out/build/MutantStandard-Regular.ttf` +3. On linux, you could also copy the font and its license to the system fonts by running `sudo install.nu` + +## License + +Everything in this repository is licensed under a MIT license, except the materials used under the repositories in the folliwing folders have their own licensing: + +- Mutant Standard emoji in `mutant_standard` are licensed CC BY-NC-SA 4.0 International +- Orxporter in `orxporter` is licensed under the Cooperative Non-Violent License (CNPL) v4 +- nanoemoji in `nanoemoji` is licensed under the Apache-2.0 license + +## Your contributions + +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the MIT license, shall be licensed as above, without any additional terms or conditions. diff --git a/build_ttf.nu b/build_ttf.nu new file mode 100755 index 0000000..caa2e72 --- /dev/null +++ b/build_ttf.nu @@ -0,0 +1,34 @@ +#!/usr/bin/nu + +# you should be running this from some venv... + +#install deps +pip install -r orxporter/requirements.txt +pip install -e nanoemoji + +#NOTE conversion from/to hex is like this +# ❯ 128488 | fmt | $in.lowerhex | str substring 2.. +# 1f5e8 +# ❯ "1f5e8" | into int --radix 16 +# 128488 + +mkdir out +python ./orxporter/orxport.py -m ./mutant_standard/manifest/out.orx -i ../input -q 32x32 -o ./out/font_sources -F svg -t 8 -f %f/%u +python ./orxporter/orxport.py -m ./mutant_standard/manifest/out.orx -i ../input -j ./out/meta.json +open ./out/meta.json | reduce -f {} {|it, acc| try { let emoji = char --integer ...($it.code); $acc | + insert ($it.code | each {|i| $i | fmt | $in.lowerhex | str substring 2..} | str join "-") { + name: $it.short, + glyph_name: (if 0 < ($it.short | find -r "^[0-9]" | length) { "_" | append $it.short | str join } else { $it.short }) + } } catch { $acc }} | to json | save -f ./out/unicode_map.json + +# remove px from lengths as picosvg (used by nanoemoji) dies from it and its fine without px probably +ls ./out/font_sources/svg/ | get name | par-each {|fp| open $fp | str replace --all -r "(:[0-9.]+)px" "$1" | save -f $fp} + +let version = open ./mutant_standard/manifest/font/manifest.json | $in.metadata.version | split row "." +let version_major = $version | get 0 +let version_minor = $version | get 1 + +cd out +#TODO figure out glyphmap generation for glyph names in ttf +# nanoemoji --color_format glyf_colr_1 --glyphmap_generator ../glyphmap_generator.nu --family "Mutant Standard" --output_file MutantStandard-Regular.ttf --version_major $version_major --version_minor $version_minor ./font_sources/svg/*.svg +nanoemoji --color_format glyf_colr_1 --family "Mutant Standard" --output_file MutantStandard-Regular.ttf --version_major $version_major --version_minor $version_minor ./font_sources/svg/*.svg diff --git a/glyphmap_generator.nu b/glyphmap_generator.nu new file mode 100755 index 0000000..2814a83 --- /dev/null +++ b/glyphmap_generator.nu @@ -0,0 +1,18 @@ +#!/usr/bin/nu + +# It is recommended to name the glyphs so here we go taking the short names. Undefined codepoints don't make it into the font unfortunately. +# according some page on the internet: http://silnrsi.github.io/FDBP/en-US/Glyph_Naming.html +# nanoemoji needs the generator to output csv like: filename,codepoints,glyphname +#TODO? this may need to be python? why no docs on glyphmap generator usage? I will keep searching... + +#NOTE conversion from/to hex is like this +# ❯ 128488 | fmt | $in.lowerhex | str substring 2.. +# 1f5e8 +# ❯ "1f5e8" | into int --radix 16 +# 128488 + +def main [...files] { + let codes_req = $files | par-each {|fp| $fp | split row "/" | last 1 | get 0 | split row "." | get 0 | {path: $fp, code: $in} } + let map = open "./out/unicode_map.json" + return ($codes_req | par-each {|e| $"($e.path),($e.code | str replace --all "-" ","),($map | get $e.code | get glyph_name)"} | str join "\n") +} diff --git a/install.nu b/install.nu new file mode 100755 index 0000000..c817399 --- /dev/null +++ b/install.nu @@ -0,0 +1,4 @@ +#!/usr/bin/nu + +cp -r ./mutant_standard/manifest/license /usr/share/licenses/ttf-mutant-standard +cp ./out/build/MutantStandard-Regular.ttf /usr/share/fonts/TTF/ diff --git a/mutant_standard b/mutant_standard new file mode 160000 index 0000000..b0f12c2 --- /dev/null +++ b/mutant_standard @@ -0,0 +1 @@ +Subproject commit b0f12c2c3477cd6ccb8484e29da43373c6238f8f diff --git a/nanoemoji b/nanoemoji new file mode 160000 index 0000000..fbd1a35 --- /dev/null +++ b/nanoemoji @@ -0,0 +1 @@ +Subproject commit fbd1a35916c2f22804a6139992d07e74480a9209 diff --git a/orxporter b/orxporter new file mode 160000 index 0000000..5e053a6 --- /dev/null +++ b/orxporter @@ -0,0 +1 @@ +Subproject commit 5e053a60503dbfd762356115e1e2ac65e97a0887