diff options
author | Rasmus Andersson <rasmus@notion.se> | 2019-01-05 23:00:00 +0300 |
---|---|---|
committer | Rasmus Andersson <rasmus@notion.se> | 2019-01-05 23:00:00 +0300 |
commit | 718930e07f8ee60f54c9a92e6ed86d41a0ddcb2a (patch) | |
tree | 5977f0ab067603d4591cc64f432d19e344acbfd7 | |
parent | dee86b504c021bd465e124360a035d72e7abaa6d (diff) | |
download | inter-718930e07f8ee60f54c9a92e6ed86d41a0ddcb2a.tar.xz |
patch fonttools instead of ufo2ft
-rwxr-xr-x | init.sh | 7 | ||||
-rwxr-xr-x | misc/fontbuild | 8 | ||||
-rw-r--r-- | misc/fonttools-3.34.2-psCharStrings.patch | 37 | ||||
-rw-r--r-- | misc/ufo2ft-2.5.0-outlineCompiler.patch | 18 | ||||
-rw-r--r-- | requirements.txt | 1 |
5 files changed, 45 insertions, 26 deletions
@@ -121,13 +121,14 @@ else date '+%s' > "$UPDATE_TIMESTAMP_FILE" fi - # patch ufo2ft [BUG #110] - P1_FILE="$VENV_DIR/lib/python/site-packages/ufo2ft/outlineCompiler.py" + # patch fonttools [BUG #110] + P1_FILE="$VENV_DIR/lib/python/site-packages/fontTools/misc/psCharStrings.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 + patch "$P1_BACKUP" -o "$P1_FILE" -u -i \ + misc/fonttools-3.34.2-psCharStrings.patch fi diff --git a/misc/fontbuild b/misc/fontbuild index 8b3e924fd..3d3d70b76 100755 --- a/misc/fontbuild +++ b/misc/fontbuild @@ -198,15 +198,13 @@ def setFontInfo(font, weight): family = font.info.familyName # i.e. "Inter UI" style = font.info.styleName # e.g. "Medium Italic" - # 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. + # Update italicAngle isitalic = False if font.info.italicAngle != 0: isitalic = True - font.info.italicAngle = round(font.info.italicAngle, 1) + font.info.italicAngle = float('%.8g' % font.info.italicAngle) else: - font.info.italicAngle = 0 + font.info.italicAngle = 0 # avoid "-0.0" value in UFO # weight font.info.openTypeOS2WeightClass = weight diff --git a/misc/fonttools-3.34.2-psCharStrings.patch b/misc/fonttools-3.34.2-psCharStrings.patch new file mode 100644 index 000000000..7be387201 --- /dev/null +++ b/misc/fonttools-3.34.2-psCharStrings.patch @@ -0,0 +1,37 @@ +--- a/fontTools/misc/psCharStrings.py ++++ b/fontTools/misc/psCharStrings.py +@@ -223,9 +223,16 @@ + else: + return b"\xff" + pack(">l", value) # encode the entire fixed point value + ++ ++realZeroBytes = bytechr(30) + bytechr(0xf) ++ + def encodeFloat(f): + # For CFF only, used in cffLib +- s = str(f).upper() ++ if f == 0.0: # 0.0 == +0.0 == -0.0 ++ return realZeroBytes ++ # Note: 14 decimal digits seems to be the limitation for CFF real numbers ++ # in macOS. However, we use 8 here to match the implementation of AFDKO. ++ s = "%.8G" % f + if s[:2] == "0.": + s = s[1:] + elif s[:3] == "-0.": +@@ -234,9 +241,13 @@ + while s: + c = s[0] + s = s[1:] +- if c == "E" and s[:1] == "-": +- s = s[1:] +- c = "E-" ++ if c == "E": ++ c2 = s[:1] ++ if c2 == "-": ++ s = s[1:] ++ c = "E-" ++ elif c2 == "+": ++ s = s[1:] + nibbles.append(realNibblesDict[c]) + nibbles.append(0xf) + if len(nibbles) % 2: diff --git a/misc/ufo2ft-2.5.0-outlineCompiler.patch b/misc/ufo2ft-2.5.0-outlineCompiler.patch deleted file mode 100644 index dd500992c..000000000 --- a/misc/ufo2ft-2.5.0-outlineCompiler.patch +++ /dev/null @@ -1,18 +0,0 @@ ---- 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/requirements.txt b/requirements.txt index 8c8580bbd..605b3659e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,6 @@ glyphsLib==3.1.4 skia-pathops==0.2.0.post2 +fonttools[ufo,lxml,unicode]==3.34.2 fontmake==1.8.0 fs==2.2.0 |