diff options
author | Rasmus Andersson <rasmus@notion.se> | 2019-01-05 22:41:37 +0300 |
---|---|---|
committer | Rasmus Andersson <rasmus@notion.se> | 2019-01-05 22:41:37 +0300 |
commit | dee86b504c021bd465e124360a035d72e7abaa6d (patch) | |
tree | 87c6bf1b9495a31b8ba1758f840edbdac5e7e493 | |
parent | f15b156c4d2bfe939a070286514ba84d9fea95ea (diff) | |
download | inter-dee86b504c021bd465e124360a035d72e7abaa6d.tar.xz |
patches ufo2ft and drops python 2 env for OTF compilation
-rw-r--r-- | Makefile | 58 | ||||
-rwxr-xr-x | init.sh | 45 | ||||
-rwxr-xr-x | misc/fontbuild | 11 | ||||
-rwxr-xr-x | misc/fontbuild2 | 6 | ||||
-rw-r--r-- | misc/ufo2ft-2.5.0-outlineCompiler.patch | 18 | ||||
-rw-r--r-- | requirements2.txt | 17 |
6 files changed, 49 insertions, 106 deletions
@@ -96,72 +96,28 @@ all_ufo_masters = $(Thin_ufo_d) \ $(FONTDIR)/var/%.var.ttf: src/%.designspace $(all_ufo_masters) misc/fontbuild compile-var -o $@ $< - -# ---------- begin workaround for issue #110 ----------- - -# $(FONTDIR)/const/Inter-UI-Thin.%: src/Inter-UI.designspace $(Thin_ufo_d) -# misc/fontbuild compile -o $@ src/Inter-UI-Thin.ufo - -# $(FONTDIR)/const/Inter-UI-ThinItalic.%: src/Inter-UI.designspace $(ThinItalic_ufo_d) -# misc/fontbuild compile -o $@ src/Inter-UI-ThinItalic.ufo - -# $(FONTDIR)/const/Inter-UI-Regular.%: src/Inter-UI.designspace $(Regular_ufo_d) -# misc/fontbuild compile -o $@ src/Inter-UI-Regular.ufo - -# $(FONTDIR)/const/Inter-UI-Italic.%: src/Inter-UI.designspace $(Italic_ufo_d) -# misc/fontbuild compile -o $@ src/Inter-UI-Italic.ufo - -# $(FONTDIR)/const/Inter-UI-Black.%: src/Inter-UI.designspace $(Black_ufo_d) -# misc/fontbuild compile -o $@ src/Inter-UI-Black.ufo - -# $(FONTDIR)/const/Inter-UI-BlackItalic.%: src/Inter-UI.designspace $(BlackItalic_ufo_d) -# misc/fontbuild compile -o $@ src/Inter-UI-BlackItalic.ufo - - -$(FONTDIR)/const/Inter-UI-Thin.ttf: src/Inter-UI.designspace $(Thin_ufo_d) +$(FONTDIR)/const/Inter-UI-Thin.%: src/Inter-UI.designspace $(Thin_ufo_d) misc/fontbuild compile -o $@ src/Inter-UI-Thin.ufo -$(FONTDIR)/const/Inter-UI-ThinItalic.ttf: src/Inter-UI.designspace $(ThinItalic_ufo_d) +$(FONTDIR)/const/Inter-UI-ThinItalic.%: src/Inter-UI.designspace $(ThinItalic_ufo_d) misc/fontbuild compile -o $@ src/Inter-UI-ThinItalic.ufo -$(FONTDIR)/const/Inter-UI-Regular.ttf: src/Inter-UI.designspace $(Regular_ufo_d) +$(FONTDIR)/const/Inter-UI-Regular.%: src/Inter-UI.designspace $(Regular_ufo_d) misc/fontbuild compile -o $@ src/Inter-UI-Regular.ufo -$(FONTDIR)/const/Inter-UI-Italic.ttf: src/Inter-UI.designspace $(Italic_ufo_d) +$(FONTDIR)/const/Inter-UI-Italic.%: src/Inter-UI.designspace $(Italic_ufo_d) misc/fontbuild compile -o $@ src/Inter-UI-Italic.ufo -$(FONTDIR)/const/Inter-UI-Black.ttf: src/Inter-UI.designspace $(Black_ufo_d) +$(FONTDIR)/const/Inter-UI-Black.%: src/Inter-UI.designspace $(Black_ufo_d) misc/fontbuild compile -o $@ src/Inter-UI-Black.ufo -$(FONTDIR)/const/Inter-UI-BlackItalic.ttf: src/Inter-UI.designspace $(BlackItalic_ufo_d) +$(FONTDIR)/const/Inter-UI-BlackItalic.%: src/Inter-UI.designspace $(BlackItalic_ufo_d) misc/fontbuild compile -o $@ src/Inter-UI-BlackItalic.ufo -$(FONTDIR)/const/Inter-UI-Thin.otf: src/Inter-UI.designspace $(Thin_ufo_d) - misc/fontbuild2 compile -o $@ src/Inter-UI-Thin.ufo - -$(FONTDIR)/const/Inter-UI-ThinItalic.otf: src/Inter-UI.designspace $(ThinItalic_ufo_d) - misc/fontbuild2 compile -o $@ src/Inter-UI-ThinItalic.ufo - -$(FONTDIR)/const/Inter-UI-Regular.otf: src/Inter-UI.designspace $(Regular_ufo_d) - misc/fontbuild2 compile -o $@ src/Inter-UI-Regular.ufo - -$(FONTDIR)/const/Inter-UI-Italic.otf: src/Inter-UI.designspace $(Italic_ufo_d) - misc/fontbuild2 compile -o $@ src/Inter-UI-Italic.ufo - -$(FONTDIR)/const/Inter-UI-Black.otf: src/Inter-UI.designspace $(Black_ufo_d) - misc/fontbuild2 compile -o $@ src/Inter-UI-Black.ufo - -$(FONTDIR)/const/Inter-UI-BlackItalic.otf: src/Inter-UI.designspace $(BlackItalic_ufo_d) - misc/fontbuild2 compile -o $@ src/Inter-UI-BlackItalic.ufo - -# ---------- end workaround for issue #110 ----------- - - # Instance UFO -> OTF, TTF - $(FONTDIR)/const/Inter-UI-%.otf: build/ufo/Inter-UI-%.ufo - misc/fontbuild2 compile -o $@ $< + misc/fontbuild compile -o $@ $< $(FONTDIR)/const/Inter-UI-%.ttf: build/ufo/Inter-UI-%.ufo misc/fontbuild compile -o $@ $< @@ -108,31 +108,11 @@ else done fi - # -------------------- - # ISSUE #110 (bug in ufo2ft) requires Python 2 for OTF CFF compilation - # See also: https://github.com/googlei18n/ufo2ft/issues/306 - PYTHON2= - if (which python2 >/dev/null); then - PYTHON2=$(which python2) - elif (which python >/dev/null) && (python --version | grep -q 'ython 2'); then - PYTHON2=$(which python) - else - echo "Unable to find Python 2 (tried python2 and python)." >&2 - echo "Python 2 is required to compile OTF files because of a Python-3 bug in a third-party library." >&2 - exit 1 - fi - # ln -svf "$PYTHON2" "$VENV_DIR/bin/python2" - VENV2_DIR=$BUILD_DIR/venv2 - if [[ ! -d "$VENV2_DIR/bin" ]]; then - require_virtualenv - $virtualenv "--python=$PYTHON2" "$VENV2_DIR" - fi # —————————————————————————————————————————————————————————————————— - # check pip requirements + # python dependencies - - # primary env + # install if deps changed REQUIREMENTS_FILE=$SRCDIR/requirements.txt UPDATE_TIMESTAMP_FILE="$VENV_DIR/last-pip-run.mark" if [ "$REQUIREMENTS_FILE" -nt "$UPDATE_TIMESTAMP_FILE" ]; then @@ -141,21 +121,24 @@ else date '+%s' > "$UPDATE_TIMESTAMP_FILE" fi - # secondary env (Python 2) - REQUIREMENTS2_FILE=$SRCDIR/requirements2.txt - UPDATE_TIMESTAMP2_FILE="$VENV2_DIR/last-pip-run.mark" - if [ "$REQUIREMENTS2_FILE" -nt "$UPDATE_TIMESTAMP2_FILE" ]; then - echo "$VENV2_DIR/bin/pip install -r $REQUIREMENTS2_FILE" - "$VENV2_DIR/bin/pip" install -r "$REQUIREMENTS2_FILE" - date '+%s' > "$UPDATE_TIMESTAMP2_FILE" + # patch ufo2ft [BUG #110] + P1_FILE="$VENV_DIR/lib/python/site-packages/ufo2ft/outlineCompiler.py" + P1_BACKUP="$P1_FILE.orig" + if [[ ! -f "$P1_BACKUP" ]]; then + echo "Patching $P1_FILE (backup at $P1_BACKUP)" + mv "$P1_FILE" "$P1_BACKUP" + patch "$P1_BACKUP" -o "$P1_FILE" -u -i misc/ufo2ft-2.5.0-outlineCompiler.patch fi + # —————————————————————————————————————————————————————————————————— - # active primary env (Python 3) + # activate env (for rest of this script) source "$VENV_DIR/bin/activate" + # —————————————————————————————————————————————————————————————————— - # deps + # other toolchain dependencies + DEPS_DIR=$BUILD_DIR/deps PATCH_DIR=$(pwd)/misc/patches mkdir -p "$DEPS_DIR" diff --git a/misc/fontbuild b/misc/fontbuild index cf5d21f68..8b3e924fd 100755 --- a/misc/fontbuild +++ b/misc/fontbuild @@ -197,7 +197,16 @@ def setFontInfo(font, weight): # family = font.info.familyName # i.e. "Inter UI" style = font.info.styleName # e.g. "Medium Italic" - isitalic = font.info.italicAngle != 0 + + # Patch italicAngle to be either positive zero or single-decimal precision + # floating-point number. + # This value can go wrong since we are using floating-point numbers. + isitalic = False + if font.info.italicAngle != 0: + isitalic = True + font.info.italicAngle = round(font.info.italicAngle, 1) + else: + font.info.italicAngle = 0 # weight font.info.openTypeOS2WeightClass = weight diff --git a/misc/fontbuild2 b/misc/fontbuild2 deleted file mode 100755 index bece1063c..000000000 --- a/misc/fontbuild2 +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -pushd "$(dirname "$0")/.." >/dev/null -SRCDIR=$(PWD) -popd >/dev/null - -"$SRCDIR/build/venv2/bin/python" misc/fontbuild "$@" diff --git a/misc/ufo2ft-2.5.0-outlineCompiler.patch b/misc/ufo2ft-2.5.0-outlineCompiler.patch new file mode 100644 index 000000000..dd500992c --- /dev/null +++ b/misc/ufo2ft-2.5.0-outlineCompiler.patch @@ -0,0 +1,18 @@ +--- a/ufo2ft/outlineCompiler.py ++++ b/ufo2ft/outlineCompiler.py +@@ -983,7 +983,14 @@ + topDict.UnderlineThickness = otRound(underlineThickness) + # populate font matrix + unitsPerEm = otRound(getAttrWithFallback(info, "unitsPerEm")) +- topDict.FontMatrix = [1.0 / unitsPerEm, 0, 0, 1.0 / unitsPerEm, 0, 0] ++ topDict.FontMatrix = [ ++ round(1.0 / unitsPerEm, 14), ++ 0, ++ 0, ++ round(1.0 / unitsPerEm, 14), ++ 0, ++ 0 ++ ] + # populate the width values + if not any(hasattr(info, attr) and getattr(info, attr) is not None + for attr in ("postscriptDefaultWidthX", diff --git a/requirements2.txt b/requirements2.txt deleted file mode 100644 index 44db5e3fd..000000000 --- a/requirements2.txt +++ /dev/null @@ -1,17 +0,0 @@ -# for secondry env (Python 2) -# should match requirements.txt except from the "Python 2 specific" section. - -glyphsLib==3.1.4 -skia-pathops==0.2.0.post2 -fontmake==1.8.0 -fs==2.2.0 - -# for fontTools/varLib/interpolatable.py -numpy==1.15.4 -scipy==1.2.0 -munkres==1.0.12 - -# Python 2 specific -enum34==1.1.6 -typing==3.6.6 -backports.os==0.1.1 |