From 6b4e2e71474b02460169bd5b9936813361c83643 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 1 Apr 2022 13:14:39 -0600 Subject: [PATCH] [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. --- Lib/fontTools/ufoLib/glifLib.py | 4 ++-- Lib/fontTools/varLib/interpolatable.py | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Lib/fontTools/ufoLib/glifLib.py b/Lib/fontTools/ufoLib/glifLib.py index 44622a148..89c9176a7 100755 --- a/Lib/fontTools/ufoLib/glifLib.py +++ b/Lib/fontTools/ufoLib/glifLib.py @@ -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): diff --git a/Lib/fontTools/varLib/interpolatable.py b/Lib/fontTools/varLib/interpolatable.py index 2954a15cb..03a8ca807 100644 --- a/Lib/fontTools/varLib/interpolatable.py +++ b/Lib/fontTools/varLib/interpolatable.py @@ -166,7 +166,10 @@ def test(glyphsets, glyphs=None, names=None): perContourPen = PerContourOrComponentPen( RecordingPen, glyphset=glyphset ) - glyph.draw(perContourPen) + try: + glyph.draw(perContourPen, outputImpliedClosingLine=True) + except TypeError: + glyph.draw(perContourPen) contourPens = perContourPen.value del perContourPen