[ufoLib / interpolatable] Wire up outputImpliedClosingLine parameter

ufoLib's glyph draw() was passing outputImpliedClosingLine=False to
PointToSegmentPen(). This was causing incompatible nodes in
interpolatable tool for certain fonts, like this in NotoSansDevanagari:

Glyph dabhadeva was not compatible:
    Node count differs in path 1: 23 in NotoSansDevanagari-Bold, 24 in NotoSansDevanagari-CondensedBold
    Node count differs in path 1: 24 in NotoSansDevanagari-CondensedBold, 23 in NotoSansDevanagari-CondensedLight

Because a final lineto before a closepath was being elided or not in
some masters but not others.  Wire up the parameter and control it
from interpolatable tool to fix this.
This commit is contained in:
Behdad Esfahbod 2022-04-01 13:14:39 -06:00
parent 3165cc132a
commit 6b4e2e7147
2 changed files with 6 additions and 3 deletions

View File

@ -95,11 +95,11 @@ class Glyph:
self.glyphName = glyphName
self.glyphSet = glyphSet
def draw(self, pen):
def draw(self, pen, outputImpliedClosingLine=False):
"""
Draw this glyph onto a *FontTools* Pen.
"""
pointPen = PointToSegmentPen(pen)
pointPen = PointToSegmentPen(pen, outputImpliedClosingLine=outputImpliedClosingLine)
self.drawPoints(pointPen)
def drawPoints(self, pointPen):

View File

@ -166,6 +166,9 @@ def test(glyphsets, glyphs=None, names=None):
perContourPen = PerContourOrComponentPen(
RecordingPen, glyphset=glyphset
)
try:
glyph.draw(perContourPen, outputImpliedClosingLine=True)
except TypeError:
glyph.draw(perContourPen)
contourPens = perContourPen.value
del perContourPen