From 9b0730c7bbb6b806f37c332479ff5bfe548683a1 Mon Sep 17 00:00:00 2001 From: Peter Oliver Date: Fri, 21 Aug 2020 15:44:05 +0100 Subject: [PATCH] Build COLR TTFs with nanoemoji MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is done via the container at https://gitlab.com/mavit/nanoemoji-container. For me, the resulting COLR TTFs work in Firefox and in the Gnome desktop on Fedora 32 (although they display rather small). Caveats: - It may be premature to replace `scfbuild` for SVG builds. If we decide to go ahead without `scfbuild`, then we’ll want to remove the remaining files related to it. If we decide to keep `scfbuild`, then we’ll want to revert those parts of this patch. In either case we’ll want to update the readme to link to the new outputs. - I’ve tested this with Podman, not Docker. Relates to #93. --- font/OpenMoji-Color.ttx | 62 +++++++++++++++++++++++++++++++++++ helpers/generate-fonts.sh | 68 +++++++++++++++++++++++++++++---------- 2 files changed, 113 insertions(+), 17 deletions(-) create mode 100644 font/OpenMoji-Color.ttx diff --git a/font/OpenMoji-Color.ttx b/font/OpenMoji-Color.ttx new file mode 100644 index 000000000..f1d5af8ed --- /dev/null +++ b/font/OpenMoji-Color.ttx @@ -0,0 +1,62 @@ + + + + + OpenMoji © HfG Schwäbisch Gmünd CC-BY-SA-4.0 + + + OpenMoji + + + Color + + + OpenMoji Color openmoji.org + + + OpenMoji Color + + + To be filled in at build time. + + + OpenMojiColor + + + Hochschule für Gestaltung Schwäbisch Gmünd + + + Hochschule für Gestaltung Schwäbisch Gmünd + + + Daniel Utz & Benedikt Groß with students of the HfG Schwäbisch Gmünd and other contributors + + + Open-source emojis for designers, developers and everyone else! http://openmoji.org/ https://github.com/hfg-gmuend/openmoji + + + http://openmoji.org/ + + + http://openmoji.org/about.html + + + Creative Commons Share Alike 4.0 + + + https://creativecommons.org/licenses/by-sa/4.0/ + + + OpenMoji + + + Color + + + OpenMoji Color + + + Regular + + + diff --git a/helpers/generate-fonts.sh b/helpers/generate-fonts.sh index 44754fa59..12bebb8b1 100755 --- a/helpers/generate-fonts.sh +++ b/helpers/generate-fonts.sh @@ -4,28 +4,62 @@ set -ueo pipefail # -- prepare assets -- cd -- "$(dirname -- "${BASH_SOURCE[0]}")"/.. || exit 1 -# copy and prepare svg assets for OpenMoji font generator -echo "👉 generate-font-glyphs.js" -helpers/generate-font-glyphs.js - # generate css file for OpenMoji fonts echo "👉 generate-font-css.js" helpers/generate-font-css.js -# -- OpenMoji font generator via scfbuild Docker -- -cd -- "$(dirname -- "${BASH_SOURCE[0]}")"/../font || exit 1 +sed 's/Color/Black/;' font/OpenMoji-Color.ttx > font/OpenMoji-Black.ttx + + +# -- OpenMoji COLR TTF font generator via nanoemoji container -- +version=$(git describe --tags) + +# If we're connected to a terminal, don't flood it with ninja output, +# and enable ^C. +if [[ -t 1 ]]; then + tty='--tty --interactive' +else + tty='' +fi -IMAGE='scfbuild:latest' -NAME='scfbuild_bash' +# FIXME: Upgrade glyf_colr_0 to glyf_colr_1 once +# https://github.com/googlefonts/colr-gradients-spec stabilises. +# +# FIXME: Switch untouchedsvgz for picosvgz when +# https://github.com/googlefonts/nanoemoji/issues/113 is fixed. +# +# FIXME: Here we build OpenMoji Black as a colour font that just happens +# to use black as the only colour. This is probably a bad idea. +# https://github.com/googlefonts/nanoemoji/issues/114 +# +for saturation in black color; do + name=OpenMoji-${saturation^} + build_dir=/mnt/build/$saturation -# is docker container "scfbuild_bash" running? -# if not ... start container -[[ "$(docker ps -f "name=$NAME" --format '{{.Names}}')" == "$NAME" ]] || -docker run --name "$NAME" --rm -t -d --volume "$PWD":/wd --workdir /wd "$IMAGE" bash + for format in glyf_colr_0 untouchedsvgz; do + mkdir -p font/$format -# generate fonts -docker exec -ti "$NAME" bash -c "/scfbuild/bin/scfbuild -c /wd/scfbuild-color.yml" -docker exec -ti "$NAME" bash -c "/scfbuild/bin/scfbuild -c /wd/scfbuild-black.yml" + docker run \ + --mount=type=bind,source="$PWD",destination=/mnt,relabel=private \ + --rm \ + $tty \ + registry.gitlab.com/mavit/nanoemoji-container:master \ + sh -c " + set -o errexit -# stop container -docker stop "$NAME" + nanoemoji \ + --color_format=$format \ + --build_dir=$build_dir \ + --output_file=$build_dir/$name.$format.ttf \ + /mnt/$saturation/svg/*.svg + xmlstarlet edit --inplace --update \ + '/ttFont/name/namerecord[@nameID=\"5\"][@platformID=\"3\"]' \ + --value '$version' \ + /mnt/font/$name.ttx + ttx \ + -m $build_dir/$name.$format.ttf \ + -o /mnt/font/$format/$name.ttf \ + /mnt/font/$name.ttx + " + done +done