Skip to content

Commit 70cd039

Browse files
committed
remove overlaps in generated fonts; update to newer FontTools API to do this
1 parent e10a1df commit 70cd039

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

scripts/dlig2calt.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def dlig2calt(fontPath, inplace=False):
5050
for glyphName in font.getGlyphNames():
5151
if font['hmtx'][glyphName][0] > unitWidth:
5252

53-
decomposeAndRemoveOverlap(font, glyphName)
53+
# decomposeAndRemoveOverlap(font, glyphName)
5454

5555
# set width to space (e.g. 600), then offset left side to be negative
5656
oldWidth = font['hmtx'][glyphName][0]
@@ -60,15 +60,17 @@ def dlig2calt(fontPath, inplace=False):
6060
font['hmtx'].__setitem__(glyphName, (unitWidth, newLSB))
6161

6262
# Adjust coordinates in glyf table
63-
coords = font['glyf'][glyphName].coordinates
64-
phantoms = font['glyf'].getPhantomPoints(glyphName, font)
63+
coords = font['glyf']._getCoordinatesAndControls(glyphName, font['hmtx'].metrics)[0]
64+
phantoms = font['glyf']._getPhantomPoints(glyphName, font['hmtx'].metrics)
65+
66+
# take off last four items of coords to allow adjusted phantoms to be handled separately, then combined
67+
coords = coords[:len(coords)-4]
6568

6669
adjustedCoords = [(x-widthDiff, y) for x, y in coords]
6770
adjustedPhantoms = [(0,0), (600,0), phantoms[-2], phantoms[-1]]
6871

6972
newCoords = adjustedCoords+adjustedPhantoms
70-
# print(glyphName, newCoords, font) # DEBUGGING
71-
font['glyf'].setCoordinates(glyphName, newCoords, font)
73+
font['glyf']._setCoordinates(glyphName, newCoords, font['hmtx'].metrics)
7274

7375

7476
# add new feature code, using calt rather than dlig

scripts/instantiate-code-fonts.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import logging
1919
import ttfautohint
2020
from fontTools.varLib import instancer
21+
from fontTools.varLib.instancer import OverlapMode
2122
from opentype_feature_freezer import cli as pyftfeatfreeze
2223
from dlig2calt import dlig2calt
2324
from mergePowerlineFont import mergePowerlineFont
@@ -100,6 +101,7 @@ def splitFont(
100101
"slnt": fontOptions["Fonts"][instance]["slnt"],
101102
"CRSV": fontOptions["Fonts"][instance]["CRSV"],
102103
},
104+
overlap=OverlapMode.REMOVE
103105
)
104106

105107
# UPDATE NAME ID 6, postscript name

0 commit comments

Comments
 (0)