From 17e95e0bd0fb2b75e4f1b9035bd61c2f47ad430a Mon Sep 17 00:00:00 2001 From: Simon Cozens Date: Mon, 7 Dec 2020 13:55:18 +0000 Subject: [PATCH 1/8] Add flattenComponents option to compileTTF --- Lib/ufo2ft/__init__.py | 2 ++ Lib/ufo2ft/preProcessor.py | 15 +++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Lib/ufo2ft/__init__.py b/Lib/ufo2ft/__init__.py index a317d6b20..6a8b90269 100644 --- a/Lib/ufo2ft/__init__.py +++ b/Lib/ufo2ft/__init__.py @@ -172,6 +172,7 @@ def compileTTF( rememberCurveType=True, removeOverlaps=False, overlapsBackend=None, + flattenComponents=None, inplace=False, layerName=None, skipExportGlyphs=None, @@ -205,6 +206,7 @@ def compileTTF( inplace=inplace, removeOverlaps=removeOverlaps, overlapsBackend=overlapsBackend, + flattenComponents=flattenComponents, convertCubics=convertCubics, conversionError=cubicConversionError, reverseDirection=reverseDirection, diff --git a/Lib/ufo2ft/preProcessor.py b/Lib/ufo2ft/preProcessor.py index 81f48781d..9d3f8da30 100644 --- a/Lib/ufo2ft/preProcessor.py +++ b/Lib/ufo2ft/preProcessor.py @@ -110,7 +110,9 @@ class TTFPreProcessor(OTFPreProcessor): """Preprocessor for building TrueType-flavored OpenType fonts. By default, it decomposes all the glyphs with mixed component/contour - outlines. + outlines. If the ``flattenComponents`` setting is True, glyphs with + nested components are flattened so that they have at most one level of + components. If ``removeOverlaps`` is True, it performs a union boolean operation on all the glyphs' contours. @@ -144,6 +146,7 @@ def initDefaultFilters( self, removeOverlaps=False, overlapsBackend=None, + flattenComponents=False, convertCubics=True, conversionError=None, reverseDirection=True, @@ -153,9 +156,13 @@ def initDefaultFilters( _init_explode_color_layer_glyphs_filter(self.ufo, filters) - # len(g) is the number of contours, so we include the all glyphs - # that have both components and at least one contour - filters.append(DecomposeComponentsFilter(include=lambda g: len(g))) + if flattenComponents: + from ufo2ft.filters.flattenComponents import FlattenComponentsFilter + filters.append(FlattenComponentsFilter()) + else: + # len(g) is the number of contours, so we include the all glyphs + # that have both components and at least one contour + filters.append(DecomposeComponentsFilter(include=lambda g: len(g))) if removeOverlaps: from ufo2ft.filters.removeOverlaps import RemoveOverlapsFilter From 895d87e3cc49b6ed7a4eed0958daa62e9f449a19 Mon Sep 17 00:00:00 2001 From: Simon Cozens Date: Mon, 7 Dec 2020 13:55:31 +0000 Subject: [PATCH 2/8] Tests for flattening components --- tests/data/NestedComponents-flat.ttx | 356 ++++++++++++++++++ tests/data/NestedComponents.ttx | 355 +++++++++++++++++ .../data/NestedComponents.ufo/fontinfo.plist | 293 ++++++++++++++ .../NestedComponents.ufo/glyphs/_notdef.glif | 18 + tests/data/NestedComponents.ufo/glyphs/a.glif | 19 + tests/data/NestedComponents.ufo/glyphs/b.glif | 27 ++ tests/data/NestedComponents.ufo/glyphs/c.glif | 14 + .../glyphs/contents.plist | 20 + tests/data/NestedComponents.ufo/glyphs/d.glif | 34 ++ tests/data/NestedComponents.ufo/glyphs/e.glif | 15 + .../NestedComponents.ufo/glyphs/space.glif | 7 + .../NestedComponents.ufo/layercontents.plist | 10 + tests/data/NestedComponents.ufo/lib.plist | 173 +++++++++ .../data/NestedComponents.ufo/metainfo.plist | 10 + tests/integration_test.py | 10 + 15 files changed, 1361 insertions(+) create mode 100644 tests/data/NestedComponents-flat.ttx create mode 100644 tests/data/NestedComponents.ttx create mode 100644 tests/data/NestedComponents.ufo/fontinfo.plist create mode 100644 tests/data/NestedComponents.ufo/glyphs/_notdef.glif create mode 100644 tests/data/NestedComponents.ufo/glyphs/a.glif create mode 100644 tests/data/NestedComponents.ufo/glyphs/b.glif create mode 100644 tests/data/NestedComponents.ufo/glyphs/c.glif create mode 100644 tests/data/NestedComponents.ufo/glyphs/contents.plist create mode 100644 tests/data/NestedComponents.ufo/glyphs/d.glif create mode 100644 tests/data/NestedComponents.ufo/glyphs/e.glif create mode 100644 tests/data/NestedComponents.ufo/glyphs/space.glif create mode 100644 tests/data/NestedComponents.ufo/layercontents.plist create mode 100644 tests/data/NestedComponents.ufo/lib.plist create mode 100644 tests/data/NestedComponents.ufo/metainfo.plist diff --git a/tests/data/NestedComponents-flat.ttx b/tests/data/NestedComponents-flat.ttx new file mode 100644 index 000000000..8b7168e27 --- /dev/null +++ b/tests/data/NestedComponents-flat.ttx @@ -0,0 +1,356 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Copyright © Some Foundry. + + + Some Font Regular (Style Map Family Name) + + + Regular + + + OpenType name Table Unique ID + + + Some Font (Preferred Family Name) Regular (Preferred Subfamily Name) + + + OpenType name Table Version + + + SomeFont-RegularPostscriptFontName + + + Trademark Some Foundry + + + Some Foundry + + + Some Designer + + + Some Font by Some Designer for Some Foundry. + + + http://somefoundry.com + + + http://somedesigner.com + + + License info for Some Foundry. + + + http://somefoundry.com/license + + + Some Font (Preferred Family Name) + + + Regular (Preferred Subfamily Name) + + + Some Font Regular (Compatible Full Name) + + + Sample Text for Some Font. + + + Some Font (WWS Family Name) + + + Regular (WWS Subfamily Name) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/data/NestedComponents.ttx b/tests/data/NestedComponents.ttx new file mode 100644 index 000000000..792c6bf9e --- /dev/null +++ b/tests/data/NestedComponents.ttx @@ -0,0 +1,355 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Copyright © Some Foundry. + + + Some Font Regular (Style Map Family Name) + + + Regular + + + OpenType name Table Unique ID + + + Some Font (Preferred Family Name) Regular (Preferred Subfamily Name) + + + OpenType name Table Version + + + SomeFont-RegularPostscriptFontName + + + Trademark Some Foundry + + + Some Foundry + + + Some Designer + + + Some Font by Some Designer for Some Foundry. + + + http://somefoundry.com + + + http://somedesigner.com + + + License info for Some Foundry. + + + http://somefoundry.com/license + + + Some Font (Preferred Family Name) + + + Regular (Preferred Subfamily Name) + + + Some Font Regular (Compatible Full Name) + + + Sample Text for Some Font. + + + Some Font (WWS Family Name) + + + Regular (WWS Subfamily Name) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/data/NestedComponents.ufo/fontinfo.plist b/tests/data/NestedComponents.ufo/fontinfo.plist new file mode 100644 index 000000000..0cf94783f --- /dev/null +++ b/tests/data/NestedComponents.ufo/fontinfo.plist @@ -0,0 +1,293 @@ + + + + + ascender + 750 + capHeight + 750 + copyright + Copyright © Some Foundry. + descender + -250 + familyName + Some Font (Family Name) + guidelines + + + angle + 0 + x + 250 + y + 0 + + + angle + 0 + x + -20 + y + 0 + + + angle + 0 + x + 30 + y + 0 + + + y + 500 + + + y + -200 + + + y + 700 + + + angle + 135 + x + 0 + y + 0 + + + angle + 45 + x + 0 + y + 700 + + + angle + 135 + x + 20 + y + 0 + + + italicAngle + -12.5 + macintoshFONDFamilyID + 15000 + macintoshFONDName + SomeFont Regular (FOND Name) + note + A note. + openTypeHeadCreated + 2000/01/01 00:00:00 + openTypeHeadFlags + + 0 + 1 + + openTypeHeadLowestRecPPEM + 10 + openTypeHheaAscender + 750 + openTypeHheaCaretOffset + 0 + openTypeHheaCaretSlopeRise + 1 + openTypeHheaCaretSlopeRun + 0 + openTypeHheaDescender + -250 + openTypeHheaLineGap + 200 + openTypeNameCompatibleFullName + Some Font Regular (Compatible Full Name) + openTypeNameDescription + Some Font by Some Designer for Some Foundry. + openTypeNameDesigner + Some Designer + openTypeNameDesignerURL + http://somedesigner.com + openTypeNameLicense + License info for Some Foundry. + openTypeNameLicenseURL + http://somefoundry.com/license + openTypeNameManufacturer + Some Foundry + openTypeNameManufacturerURL + http://somefoundry.com + openTypeNamePreferredFamilyName + Some Font (Preferred Family Name) + openTypeNamePreferredSubfamilyName + Regular (Preferred Subfamily Name) + openTypeNameSampleText + Sample Text for Some Font. + openTypeNameUniqueID + OpenType name Table Unique ID + openTypeNameVersion + OpenType name Table Version + openTypeNameWWSFamilyName + Some Font (WWS Family Name) + openTypeNameWWSSubfamilyName + Regular (WWS Subfamily Name) + openTypeOS2CodePageRanges + + 0 + 1 + + openTypeOS2FamilyClass + + 1 + 1 + + openTypeOS2Panose + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + openTypeOS2Selection + + 3 + + openTypeOS2StrikeoutPosition + 300 + openTypeOS2StrikeoutSize + 20 + openTypeOS2SubscriptXOffset + 0 + openTypeOS2SubscriptXSize + 200 + openTypeOS2SubscriptYOffset + -100 + openTypeOS2SubscriptYSize + 400 + openTypeOS2SuperscriptXOffset + 0 + openTypeOS2SuperscriptXSize + 200 + openTypeOS2SuperscriptYOffset + 200 + openTypeOS2SuperscriptYSize + 400 + openTypeOS2Type + + openTypeOS2TypoAscender + 750 + openTypeOS2TypoDescender + -250 + openTypeOS2TypoLineGap + 200 + openTypeOS2UnicodeRanges + + 0 + 1 + + openTypeOS2VendorID + SOME + openTypeOS2WeightClass + 500 + openTypeOS2WidthClass + 5 + openTypeOS2WinAscent + 750 + openTypeOS2WinDescent + 250 + openTypeVheaCaretOffset + 0 + openTypeVheaCaretSlopeRise + 0 + openTypeVheaCaretSlopeRun + 1 + openTypeVheaVertTypoAscender + 750 + openTypeVheaVertTypoDescender + -250 + openTypeVheaVertTypoLineGap + 200 + postscriptBlueFuzz + 1 + postscriptBlueScale + 0.04 + postscriptBlueShift + 7 + postscriptBlueValues + + -260 + -250 + 500 + 510 + + postscriptDefaultCharacter + .notdef + postscriptDefaultWidthX + 400 + postscriptFamilyBlues + + 500 + 510 + + postscriptFamilyOtherBlues + + -260 + -250 + + postscriptFontName + SomeFont-RegularPostscriptFontName + postscriptForceBold + + postscriptFullName + Some Font-Regular (Postscript Full Name) + postscriptIsFixedPitch + + postscriptNominalWidthX + 400.0 + postscriptOtherBlues + + postscriptSlantAngle + -12.5 + postscriptStemSnapH + + 100 + 120 + + postscriptStemSnapV + + 80 + 90 + + postscriptUniqueID + 4000000 + postscriptWindowsCharacterSet + 1 + styleMapFamilyName + Some Font Regular (Style Map Family Name) + styleMapStyleName + regular + styleName + Regular (Preferred Subfamily Name) + trademark + Trademark Some Foundry + unitsPerEm + 1000 + versionMajor + 1 + versionMinor + 0 + xHeight + 500 + year + 2008 + + diff --git a/tests/data/NestedComponents.ufo/glyphs/_notdef.glif b/tests/data/NestedComponents.ufo/glyphs/_notdef.glif new file mode 100644 index 000000000..571e17ff8 --- /dev/null +++ b/tests/data/NestedComponents.ufo/glyphs/_notdef.glif @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/tests/data/NestedComponents.ufo/glyphs/a.glif b/tests/data/NestedComponents.ufo/glyphs/a.glif new file mode 100644 index 000000000..56491bef3 --- /dev/null +++ b/tests/data/NestedComponents.ufo/glyphs/a.glif @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + com.schriftgestaltung.Glyphs.lastChange + 2020-12-07 11:48:13 +0000 + + + diff --git a/tests/data/NestedComponents.ufo/glyphs/b.glif b/tests/data/NestedComponents.ufo/glyphs/b.glif new file mode 100644 index 000000000..e1c7ad72f --- /dev/null +++ b/tests/data/NestedComponents.ufo/glyphs/b.glif @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + com.schriftgestaltung.Glyphs.lastChange + 2020-12-07 11:48:16 +0000 + + + diff --git a/tests/data/NestedComponents.ufo/glyphs/c.glif b/tests/data/NestedComponents.ufo/glyphs/c.glif new file mode 100644 index 000000000..416f8bdc4 --- /dev/null +++ b/tests/data/NestedComponents.ufo/glyphs/c.glif @@ -0,0 +1,14 @@ + + + + + + + + + + com.schriftgestaltung.Glyphs.lastChange + 2020-12-07 11:48:18 +0000 + + + diff --git a/tests/data/NestedComponents.ufo/glyphs/contents.plist b/tests/data/NestedComponents.ufo/glyphs/contents.plist new file mode 100644 index 000000000..f47769123 --- /dev/null +++ b/tests/data/NestedComponents.ufo/glyphs/contents.plist @@ -0,0 +1,20 @@ + + + + + .notdef + _notdef.glif + a + a.glif + b + b.glif + c + c.glif + d + d.glif + e + e.glif + space + space.glif + + diff --git a/tests/data/NestedComponents.ufo/glyphs/d.glif b/tests/data/NestedComponents.ufo/glyphs/d.glif new file mode 100644 index 000000000..ffd1d3461 --- /dev/null +++ b/tests/data/NestedComponents.ufo/glyphs/d.glif @@ -0,0 +1,34 @@ + + + + + + + + + + + com.schriftgestaltung.Glyphs.ComponentInfo + + + alignment + -1 + index + 0 + name + b + + + alignment + -1 + index + 1 + name + a + + + com.schriftgestaltung.Glyphs.lastChange + 2020-12-07 11:48:21 +0000 + + + diff --git a/tests/data/NestedComponents.ufo/glyphs/e.glif b/tests/data/NestedComponents.ufo/glyphs/e.glif new file mode 100644 index 000000000..329315f69 --- /dev/null +++ b/tests/data/NestedComponents.ufo/glyphs/e.glif @@ -0,0 +1,15 @@ + + + + + + + + + + + com.schriftgestaltung.Glyphs.lastChange + 2020-12-07 11:48:37 +0000 + + + diff --git a/tests/data/NestedComponents.ufo/glyphs/space.glif b/tests/data/NestedComponents.ufo/glyphs/space.glif new file mode 100644 index 000000000..bbc0a0506 --- /dev/null +++ b/tests/data/NestedComponents.ufo/glyphs/space.glif @@ -0,0 +1,7 @@ + + + + + + + diff --git a/tests/data/NestedComponents.ufo/layercontents.plist b/tests/data/NestedComponents.ufo/layercontents.plist new file mode 100644 index 000000000..cf95d3573 --- /dev/null +++ b/tests/data/NestedComponents.ufo/layercontents.plist @@ -0,0 +1,10 @@ + + + + + + public.default + glyphs + + + diff --git a/tests/data/NestedComponents.ufo/lib.plist b/tests/data/NestedComponents.ufo/lib.plist new file mode 100644 index 000000000..11c81487f --- /dev/null +++ b/tests/data/NestedComponents.ufo/lib.plist @@ -0,0 +1,173 @@ + + + + + com.schriftgestaltung.DisplayStrings + + e + + com.schriftgestaltung.disablesAutomaticAlignment + + com.schriftgestaltung.font.customParameters + + + name + glyphOrder + value + + .notdef + glyph1 + glyph2 + space + a + b + c + d + e + f + g + h + i + j + k + l + + + + name + openTypeGaspRangeRecords + value + + + rangeGaspBehavior + + 1 + 3 + + rangeMaxPPEM + 7 + + + rangeGaspBehavior + + 0 + 1 + 2 + 3 + + rangeMaxPPEM + 65535 + + + + + name + openTypeNameRecords + value + + + encodingID + 0 + languageID + 0 + nameID + 3 + platformID + 1 + string + Unique Font Identifier + + + encodingID + 1 + languageID + 1033 + nameID + 8 + platformID + 3 + string + Some Foundry (Manufacturer Name) + + + + + com.schriftgestaltung.fontMaster.customParameters + + + name + underlineThickness + value + 20 + + + name + underlinePosition + value + -200 + + + com.schriftgestaltung.fontMasterID + master01 + com.schriftgestaltung.glyphOrder + + .notdef + glyph1 + glyph2 + space + a + b + c + d + e + f + g + h + i + j + k + l + + com.schriftgestaltung.useNiceNames + + public.glyphOrder + + .notdef + space + a + b + c + d + e + + public.postscriptNames + + a + uni0061 + b + uni0062 + c + uni0063 + d + uni0064 + e + uni0065 + f + uni0066 + g + uni0067 + h + uni0068 + i + uni0069 + j + uni006A + k + uni006B + l + uni006C + space + uni0020 + + + diff --git a/tests/data/NestedComponents.ufo/metainfo.plist b/tests/data/NestedComponents.ufo/metainfo.plist new file mode 100644 index 000000000..74e4b3b4f --- /dev/null +++ b/tests/data/NestedComponents.ufo/metainfo.plist @@ -0,0 +1,10 @@ + + + + + creator + com.schriftgestaltung.GlyphsUFOExport + formatVersion + 3 + + diff --git a/tests/integration_test.py b/tests/integration_test.py index 993e219c9..6c715b4f0 100644 --- a/tests/integration_test.py +++ b/tests/integration_test.py @@ -119,6 +119,16 @@ def test_removeOverlaps_pathops(self, testufo): ttf = compileTTF(testufo, removeOverlaps=True, overlapsBackend="pathops") expectTTX(ttf, "TestFont-NoOverlaps-TTF-pathops.ttx") + def test_nestedComponents_noFlatten(self, FontClass): + ufo = FontClass(getpath("NestedComponents.ufo")) + ttf = compileTTF(ufo) + expectTTX(ttf, "NestedComponents.ttx") + + def test_nestedComponents_flatten(self, FontClass): + ufo = FontClass(getpath("NestedComponents.ufo")) + ttf = compileTTF(ufo, flattenComponents=True) + expectTTX(ttf, "NestedComponents-flat.ttx") + def test_interpolatableTTFs_lazy(self, FontClass): # two same UFOs **must** be interpolatable ufos = [FontClass(getpath("TestFont.ufo")) for _ in range(2)] From 5be6083da9d686ed845874e19172daee027e37fe Mon Sep 17 00:00:00 2001 From: Simon Cozens Date: Wed, 9 Dec 2020 16:27:01 +0000 Subject: [PATCH 3/8] Always decompose --- Lib/ufo2ft/preProcessor.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Lib/ufo2ft/preProcessor.py b/Lib/ufo2ft/preProcessor.py index 9d3f8da30..111529f52 100644 --- a/Lib/ufo2ft/preProcessor.py +++ b/Lib/ufo2ft/preProcessor.py @@ -159,10 +159,10 @@ def initDefaultFilters( if flattenComponents: from ufo2ft.filters.flattenComponents import FlattenComponentsFilter filters.append(FlattenComponentsFilter()) - else: - # len(g) is the number of contours, so we include the all glyphs - # that have both components and at least one contour - filters.append(DecomposeComponentsFilter(include=lambda g: len(g))) + + # len(g) is the number of contours, so we include the all glyphs + # that have both components and at least one contour + filters.append(DecomposeComponentsFilter(include=lambda g: len(g))) if removeOverlaps: from ufo2ft.filters.removeOverlaps import RemoveOverlapsFilter From c1cc0595adcd2c00ee30714e792d76c79dd675cc Mon Sep 17 00:00:00 2001 From: Simon Cozens Date: Wed, 9 Dec 2020 16:38:23 +0000 Subject: [PATCH 4/8] Allow flattening interpolatable and variable TTFs --- Lib/ufo2ft/__init__.py | 9 +++++++++ Lib/ufo2ft/preProcessor.py | 11 +++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Lib/ufo2ft/__init__.py b/Lib/ufo2ft/__init__.py index 6a8b90269..ab93b5a33 100644 --- a/Lib/ufo2ft/__init__.py +++ b/Lib/ufo2ft/__init__.py @@ -183,6 +183,9 @@ def compileTTF( *removeOverlaps* performs a union operation on all the glyphs' contours. + *flattenComponents* un-nests glyphs so that they have at most one level of + components. + *convertCubics* and *cubicConversionError* specify how the conversion from cubic to quadratic curves should be handled. @@ -249,6 +252,7 @@ def compileInterpolatableTTFs( useProductionNames=None, cubicConversionError=None, reverseDirection=True, + flattenComponents=None, inplace=False, layerNames=None, skipExportGlyphs=None, @@ -292,6 +296,7 @@ def compileInterpolatableTTFs( ufos, inplace=inplace, conversionError=cubicConversionError, + flattenComponents=flattenComponents, reverseDirection=reverseDirection, layerNames=layerNames, skipExportGlyphs=skipExportGlyphs, @@ -355,6 +360,7 @@ def compileInterpolatableTTFsFromDS( useProductionNames=None, cubicConversionError=None, reverseDirection=True, + flattenComponents=None, inplace=False, debugFeatureFile=None, notdefGlyph=None, @@ -409,6 +415,7 @@ def compileInterpolatableTTFsFromDS( useProductionNames=useProductionNames, cubicConversionError=cubicConversionError, reverseDirection=reverseDirection, + flattenComponents=flattenComponents, inplace=inplace, layerNames=layerNames, skipExportGlyphs=skipExportGlyphs, @@ -570,6 +577,7 @@ def compileVariableTTF( reverseDirection=True, excludeVariationTables=(), optimizeGvar=True, + flattenComponents=None, inplace=False, debugFeatureFile=None, notdefGlyph=None, @@ -599,6 +607,7 @@ def compileVariableTTF( useProductionNames=False, # will rename glyphs after varfont is built cubicConversionError=cubicConversionError, reverseDirection=reverseDirection, + flattenComponents=flattenComponents, inplace=inplace, debugFeatureFile=debugFeatureFile, notdefGlyph=notdefGlyph, diff --git a/Lib/ufo2ft/preProcessor.py b/Lib/ufo2ft/preProcessor.py index 111529f52..fd9401e6f 100644 --- a/Lib/ufo2ft/preProcessor.py +++ b/Lib/ufo2ft/preProcessor.py @@ -203,14 +203,16 @@ class TTFInterpolatablePreProcessor(object): be interpolation compatible, depending on the particular filter used or whether they are applied to only some vs all of the UFOs. - The ``conversionError``, ``reverseDirection`` and ``rememberCurveType`` - arguments work in the same way as in the ``TTFPreProcessor``. + The ``conversionError``, ``reverseDirection``, ``flattenComponents`` and + ``rememberCurveType`` arguments work in the same way as in the + ``TTFPreProcessor``. """ def __init__( self, ufos, inplace=False, + flattenComponents=False, conversionError=None, reverseDirection=True, rememberCurveType=True, @@ -221,6 +223,7 @@ def __init__( self.ufos = ufos self.inplace = inplace + self.flattenComponents = flattenComponents if layerNames is None: layerNames = [None] * len(ufos) @@ -263,6 +266,10 @@ def process(self): remember_curve_type=self._rememberCurveType and self.inplace, ) + if self.flattenComponents: + from ufo2ft.filters.flattenComponents import FlattenComponentsFilter + FlattenComponentsFilter()(ufo, glyphSet) + decompose = DecomposeComponentsFilter(include=lambda g: len(g)) for ufo, glyphSet in zip(self.ufos, self.glyphSets): decompose(ufo, glyphSet) From 2c2a7cec1d9cdee9ec93cf165b2c92e4807024ca Mon Sep 17 00:00:00 2001 From: Simon Cozens Date: Wed, 9 Dec 2020 16:49:03 +0000 Subject: [PATCH 5/8] Swap order of filters --- Lib/ufo2ft/preProcessor.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Lib/ufo2ft/preProcessor.py b/Lib/ufo2ft/preProcessor.py index fd9401e6f..b5d42d0c2 100644 --- a/Lib/ufo2ft/preProcessor.py +++ b/Lib/ufo2ft/preProcessor.py @@ -156,14 +156,14 @@ def initDefaultFilters( _init_explode_color_layer_glyphs_filter(self.ufo, filters) - if flattenComponents: - from ufo2ft.filters.flattenComponents import FlattenComponentsFilter - filters.append(FlattenComponentsFilter()) - # len(g) is the number of contours, so we include the all glyphs # that have both components and at least one contour filters.append(DecomposeComponentsFilter(include=lambda g: len(g))) + if flattenComponents: + from ufo2ft.filters.flattenComponents import FlattenComponentsFilter + filters.append(FlattenComponentsFilter()) + if removeOverlaps: from ufo2ft.filters.removeOverlaps import RemoveOverlapsFilter @@ -266,14 +266,14 @@ def process(self): remember_curve_type=self._rememberCurveType and self.inplace, ) - if self.flattenComponents: - from ufo2ft.filters.flattenComponents import FlattenComponentsFilter - FlattenComponentsFilter()(ufo, glyphSet) - decompose = DecomposeComponentsFilter(include=lambda g: len(g)) for ufo, glyphSet in zip(self.ufos, self.glyphSets): decompose(ufo, glyphSet) + if self.flattenComponents: + from ufo2ft.filters.flattenComponents import FlattenComponentsFilter + FlattenComponentsFilter()(ufo, glyphSet) + # finally apply all custom post-filters for funcs, ufo, glyphSet in zip(self.postFilters, self.ufos, self.glyphSets): for func in funcs: From 3540dc054f48e4be9c5c4aadbdec5229e40fc534 Mon Sep 17 00:00:00 2001 From: Simon Cozens Date: Wed, 9 Dec 2020 17:19:09 +0000 Subject: [PATCH 6/8] Process multiple ufos --- Lib/ufo2ft/preProcessor.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Lib/ufo2ft/preProcessor.py b/Lib/ufo2ft/preProcessor.py index b5d42d0c2..37089c1ec 100644 --- a/Lib/ufo2ft/preProcessor.py +++ b/Lib/ufo2ft/preProcessor.py @@ -272,7 +272,8 @@ def process(self): if self.flattenComponents: from ufo2ft.filters.flattenComponents import FlattenComponentsFilter - FlattenComponentsFilter()(ufo, glyphSet) + for ufo, glyphSet in zip(self.ufos, self.glyphSets): + FlattenComponentsFilter()(ufo, glyphSet) # finally apply all custom post-filters for funcs, ufo, glyphSet in zip(self.postFilters, self.ufos, self.glyphSets): From 80bd026a113aa5936d62cda687352669defb2a14 Mon Sep 17 00:00:00 2001 From: Simon Cozens Date: Wed, 9 Dec 2020 17:27:38 +0000 Subject: [PATCH 7/8] More tests --- .../NestedComponents-Bold.ufo/fontinfo.plist | 189 ++++++++++ .../glyphs/_notdef.glif | 18 + .../NestedComponents-Bold.ufo/glyphs/a.glif | 13 + .../NestedComponents-Bold.ufo/glyphs/b.glif | 21 ++ .../NestedComponents-Bold.ufo/glyphs/c.glif | 23 ++ .../glyphs/contents.plist | 0 .../NestedComponents-Bold.ufo/glyphs/d.glif | 32 ++ .../NestedComponents-Bold.ufo/glyphs/e.glif | 32 ++ .../glyphs/space.glif | 7 + .../layercontents.plist | 0 .../data/NestedComponents-Bold.ufo/lib.plist | 143 +++++++ .../metainfo.plist | 0 .../fontinfo.plist | 47 +-- .../glyphs/_notdef.glif | 0 .../glyphs/a.glif | 0 .../glyphs/b.glif | 27 ++ .../glyphs/c.glif | 11 + .../glyphs/contents.plist | 20 + .../glyphs/d.glif | 2 +- .../glyphs/e.glif | 34 ++ .../glyphs/space.glif | 0 .../layercontents.plist | 10 + .../lib.plist | 54 +-- .../metainfo.plist | 10 + tests/data/NestedComponents-flat.ttx | 356 ------------------ tests/data/NestedComponents.ttx | 355 ----------------- tests/data/NestedComponents.ufo/glyphs/b.glif | 27 -- tests/data/NestedComponents.ufo/glyphs/e.glif | 15 - tests/integration_test.py | 21 +- 29 files changed, 639 insertions(+), 828 deletions(-) create mode 100644 tests/data/NestedComponents-Bold.ufo/fontinfo.plist create mode 100644 tests/data/NestedComponents-Bold.ufo/glyphs/_notdef.glif create mode 100644 tests/data/NestedComponents-Bold.ufo/glyphs/a.glif create mode 100644 tests/data/NestedComponents-Bold.ufo/glyphs/b.glif create mode 100644 tests/data/NestedComponents-Bold.ufo/glyphs/c.glif rename tests/data/{NestedComponents.ufo => NestedComponents-Bold.ufo}/glyphs/contents.plist (100%) create mode 100644 tests/data/NestedComponents-Bold.ufo/glyphs/d.glif create mode 100644 tests/data/NestedComponents-Bold.ufo/glyphs/e.glif create mode 100644 tests/data/NestedComponents-Bold.ufo/glyphs/space.glif rename tests/data/{NestedComponents.ufo => NestedComponents-Bold.ufo}/layercontents.plist (100%) create mode 100644 tests/data/NestedComponents-Bold.ufo/lib.plist rename tests/data/{NestedComponents.ufo => NestedComponents-Bold.ufo}/metainfo.plist (100%) rename tests/data/{NestedComponents.ufo => NestedComponents-Regular.ufo}/fontinfo.plist (86%) rename tests/data/{NestedComponents.ufo => NestedComponents-Regular.ufo}/glyphs/_notdef.glif (100%) rename tests/data/{NestedComponents.ufo => NestedComponents-Regular.ufo}/glyphs/a.glif (100%) create mode 100644 tests/data/NestedComponents-Regular.ufo/glyphs/b.glif rename tests/data/{NestedComponents.ufo => NestedComponents-Regular.ufo}/glyphs/c.glif (54%) create mode 100644 tests/data/NestedComponents-Regular.ufo/glyphs/contents.plist rename tests/data/{NestedComponents.ufo => NestedComponents-Regular.ufo}/glyphs/d.glif (93%) create mode 100644 tests/data/NestedComponents-Regular.ufo/glyphs/e.glif rename tests/data/{NestedComponents.ufo => NestedComponents-Regular.ufo}/glyphs/space.glif (100%) create mode 100644 tests/data/NestedComponents-Regular.ufo/layercontents.plist rename tests/data/{NestedComponents.ufo => NestedComponents-Regular.ufo}/lib.plist (81%) create mode 100644 tests/data/NestedComponents-Regular.ufo/metainfo.plist delete mode 100644 tests/data/NestedComponents-flat.ttx delete mode 100644 tests/data/NestedComponents.ttx delete mode 100644 tests/data/NestedComponents.ufo/glyphs/b.glif delete mode 100644 tests/data/NestedComponents.ufo/glyphs/e.glif diff --git a/tests/data/NestedComponents-Bold.ufo/fontinfo.plist b/tests/data/NestedComponents-Bold.ufo/fontinfo.plist new file mode 100644 index 000000000..a4f1c263f --- /dev/null +++ b/tests/data/NestedComponents-Bold.ufo/fontinfo.plist @@ -0,0 +1,189 @@ + + + + + ascender + 750 + capHeight + 750 + descender + -250 + italicAngle + -12.5 + macintoshFONDFamilyID + 15000 + macintoshFONDName + SomeFont Regular (FOND Name) + note + A note. + openTypeHeadCreated + 2000/01/01 00:00:00 + openTypeHeadFlags + + 0 + 1 + + openTypeHeadLowestRecPPEM + 10 + openTypeHheaCaretOffset + 0 + openTypeHheaCaretSlopeRise + 1 + openTypeHheaCaretSlopeRun + 0 + openTypeNameCompatibleFullName + Some Font Regular (Compatible Full Name) + openTypeNameDescription + Some Font by Some Designer for Some Foundry. + openTypeNameDesigner + Some Designer + openTypeNameDesignerURL + http://somedesigner.com + openTypeNameLicense + License info for Some Foundry. + openTypeNameLicenseURL + http://somefoundry.com/license + openTypeNameManufacturer + Some Foundry + openTypeNameManufacturerURL + http://somefoundry.com + openTypeNamePreferredFamilyName + Some Font (Preferred Family Name) + openTypeNameSampleText + Sample Text for Some Font. + openTypeNameUniqueID + OpenType name Table Unique ID + openTypeNameVersion + OpenType name Table Version + openTypeNameWWSFamilyName + Some Font (WWS Family Name) + openTypeNameWWSSubfamilyName + Regular (WWS Subfamily Name) + openTypeOS2CodePageRanges + + 0 + + openTypeOS2FamilyClass + + 1 + 1 + + openTypeOS2Panose + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + + openTypeOS2Selection + + 3 + + openTypeOS2SubscriptXOffset + 0 + openTypeOS2SubscriptXSize + 200 + openTypeOS2SubscriptYOffset + -100 + openTypeOS2SubscriptYSize + 400 + openTypeOS2SuperscriptXOffset + 0 + openTypeOS2SuperscriptXSize + 200 + openTypeOS2SuperscriptYOffset + 200 + openTypeOS2SuperscriptYSize + 400 + openTypeOS2Type + + openTypeOS2UnicodeRanges + + 0 + 1 + + openTypeOS2VendorID + SOME + openTypeVheaCaretOffset + 0 + openTypeVheaCaretSlopeRise + 0 + openTypeVheaCaretSlopeRun + 1 + openTypeVheaVertTypoAscender + 750 + openTypeVheaVertTypoDescender + -250 + openTypeVheaVertTypoLineGap + 200 + postscriptBlueFuzz + 1 + postscriptBlueScale + 0.04 + postscriptBlueShift + 7 + postscriptBlueValues + + 500.0 + 510.0 + + postscriptDefaultCharacter + .notdef + postscriptDefaultWidthX + 400 + postscriptFamilyBlues + + 500.0 + 510.0 + + postscriptFamilyOtherBlues + + -260.0 + -250.0 + + postscriptForceBold + + postscriptIsFixedPitch + + postscriptNominalWidthX + 400.0 + postscriptOtherBlues + + postscriptSlantAngle + -12.5 + postscriptStemSnapH + + 0.0 + 0.0 + + postscriptStemSnapV + + 0.0 + 0.0 + + postscriptUniqueID + 4000000 + postscriptWindowsCharacterSet + 1 + styleName + Regular + trademark + Trademark Some Foundry + unitsPerEm + 1000 + versionMajor + 1 + versionMinor + 0 + xHeight + 500 + year + 2008 + + diff --git a/tests/data/NestedComponents-Bold.ufo/glyphs/_notdef.glif b/tests/data/NestedComponents-Bold.ufo/glyphs/_notdef.glif new file mode 100644 index 000000000..ba2587f06 --- /dev/null +++ b/tests/data/NestedComponents-Bold.ufo/glyphs/_notdef.glif @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/tests/data/NestedComponents-Bold.ufo/glyphs/a.glif b/tests/data/NestedComponents-Bold.ufo/glyphs/a.glif new file mode 100644 index 000000000..68335b673 --- /dev/null +++ b/tests/data/NestedComponents-Bold.ufo/glyphs/a.glif @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/tests/data/NestedComponents-Bold.ufo/glyphs/b.glif b/tests/data/NestedComponents-Bold.ufo/glyphs/b.glif new file mode 100644 index 000000000..050a9afab --- /dev/null +++ b/tests/data/NestedComponents-Bold.ufo/glyphs/b.glif @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/data/NestedComponents-Bold.ufo/glyphs/c.glif b/tests/data/NestedComponents-Bold.ufo/glyphs/c.glif new file mode 100644 index 000000000..7aa3a9a77 --- /dev/null +++ b/tests/data/NestedComponents-Bold.ufo/glyphs/c.glif @@ -0,0 +1,23 @@ + + + + + + + + + + com.schriftgestaltung.Glyphs.ComponentInfo + + + alignment + -1 + index + 0 + name + a + + + + + diff --git a/tests/data/NestedComponents.ufo/glyphs/contents.plist b/tests/data/NestedComponents-Bold.ufo/glyphs/contents.plist similarity index 100% rename from tests/data/NestedComponents.ufo/glyphs/contents.plist rename to tests/data/NestedComponents-Bold.ufo/glyphs/contents.plist diff --git a/tests/data/NestedComponents-Bold.ufo/glyphs/d.glif b/tests/data/NestedComponents-Bold.ufo/glyphs/d.glif new file mode 100644 index 000000000..7a79ecb9f --- /dev/null +++ b/tests/data/NestedComponents-Bold.ufo/glyphs/d.glif @@ -0,0 +1,32 @@ + + + + + + + + + + + com.schriftgestaltung.Glyphs.ComponentInfo + + + alignment + -1 + index + 0 + name + b + + + alignment + -1 + index + 1 + name + a + + + + + diff --git a/tests/data/NestedComponents-Bold.ufo/glyphs/e.glif b/tests/data/NestedComponents-Bold.ufo/glyphs/e.glif new file mode 100644 index 000000000..cd8cc9cb6 --- /dev/null +++ b/tests/data/NestedComponents-Bold.ufo/glyphs/e.glif @@ -0,0 +1,32 @@ + + + + + + + + + + + com.schriftgestaltung.Glyphs.ComponentInfo + + + alignment + -1 + index + 0 + name + c + + + alignment + -1 + index + 1 + name + d + + + + + diff --git a/tests/data/NestedComponents-Bold.ufo/glyphs/space.glif b/tests/data/NestedComponents-Bold.ufo/glyphs/space.glif new file mode 100644 index 000000000..95c4372cf --- /dev/null +++ b/tests/data/NestedComponents-Bold.ufo/glyphs/space.glif @@ -0,0 +1,7 @@ + + + + + + + diff --git a/tests/data/NestedComponents.ufo/layercontents.plist b/tests/data/NestedComponents-Bold.ufo/layercontents.plist similarity index 100% rename from tests/data/NestedComponents.ufo/layercontents.plist rename to tests/data/NestedComponents-Bold.ufo/layercontents.plist diff --git a/tests/data/NestedComponents-Bold.ufo/lib.plist b/tests/data/NestedComponents-Bold.ufo/lib.plist new file mode 100644 index 000000000..ae49b07cb --- /dev/null +++ b/tests/data/NestedComponents-Bold.ufo/lib.plist @@ -0,0 +1,143 @@ + + + + + com.schriftgestaltung.disablesAutomaticAlignment + + com.schriftgestaltung.font.customParameters + + + name + openTypeGaspRangeRecords + value + + + rangeGaspBehavior + + 1 + 3 + + rangeMaxPPEM + 7 + + + rangeGaspBehavior + + 0 + 1 + 2 + 3 + + rangeMaxPPEM + 65535 + + + + + name + openTypeNameRecords + value + + + encodingID + 0 + languageID + 0 + nameID + 3 + platformID + 1 + string + Unique Font Identifier + + + encodingID + 1 + languageID + 1033 + nameID + 8 + platformID + 3 + string + Some Foundry (Manufacturer Name) + + + + + com.schriftgestaltung.font.userData + + GSDimensionPlugin.Dimensions + + master01 + + + + com.schriftgestaltung.fontMasterID + 0A7BF222-74C5-44F5-877F-4AAEDEB31DD5 + com.schriftgestaltung.glyphOrder + + .notdef + glyph1 + glyph2 + space + a + b + c + d + e + f + g + h + i + j + k + l + + com.schriftgestaltung.master.name + Bold + com.schriftgestaltung.useNiceNames + + com.schriftgestaltung.weightValue + 800 + public.glyphOrder + + .notdef + space + a + b + c + d + e + + public.postscriptNames + + a + uni0061 + b + uni0062 + c + uni0063 + d + uni0064 + e + uni0065 + f + uni0066 + g + uni0067 + h + uni0068 + i + uni0069 + j + uni006A + k + uni006B + l + uni006C + space + uni0020 + + + diff --git a/tests/data/NestedComponents.ufo/metainfo.plist b/tests/data/NestedComponents-Bold.ufo/metainfo.plist similarity index 100% rename from tests/data/NestedComponents.ufo/metainfo.plist rename to tests/data/NestedComponents-Bold.ufo/metainfo.plist diff --git a/tests/data/NestedComponents.ufo/fontinfo.plist b/tests/data/NestedComponents-Regular.ufo/fontinfo.plist similarity index 86% rename from tests/data/NestedComponents.ufo/fontinfo.plist rename to tests/data/NestedComponents-Regular.ufo/fontinfo.plist index 0cf94783f..ff553b8a8 100644 --- a/tests/data/NestedComponents.ufo/fontinfo.plist +++ b/tests/data/NestedComponents-Regular.ufo/fontinfo.plist @@ -6,12 +6,8 @@ 750 capHeight 750 - copyright - Copyright © Some Foundry. descender -250 - familyName - Some Font (Family Name) guidelines @@ -122,8 +118,6 @@ http://somefoundry.com openTypeNamePreferredFamilyName Some Font (Preferred Family Name) - openTypeNamePreferredSubfamilyName - Regular (Preferred Subfamily Name) openTypeNameSampleText Sample Text for Some Font. openTypeNameUniqueID @@ -137,7 +131,6 @@ openTypeOS2CodePageRanges 0 - 1 openTypeOS2FamilyClass @@ -196,10 +189,6 @@ openTypeOS2VendorID SOME - openTypeOS2WeightClass - 500 - openTypeOS2WidthClass - 5 openTypeOS2WinAscent 750 openTypeOS2WinDescent @@ -224,10 +213,8 @@ 7 postscriptBlueValues - -260 - -250 - 500 - 510 + 500.0 + 510.0 postscriptDefaultCharacter .notdef @@ -235,20 +222,16 @@ 400 postscriptFamilyBlues - 500 - 510 + 500.0 + 510.0 postscriptFamilyOtherBlues - -260 - -250 + -260.0 + -250.0 - postscriptFontName - SomeFont-RegularPostscriptFontName postscriptForceBold - postscriptFullName - Some Font-Regular (Postscript Full Name) postscriptIsFixedPitch postscriptNominalWidthX @@ -259,24 +242,24 @@ -12.5 postscriptStemSnapH - 100 - 120 + 100.0 + 120.0 postscriptStemSnapV - 80 - 90 + 80.0 + 90.0 + postscriptUnderlinePosition + -200 + postscriptUnderlineThickness + 20 postscriptUniqueID 4000000 postscriptWindowsCharacterSet 1 - styleMapFamilyName - Some Font Regular (Style Map Family Name) - styleMapStyleName - regular styleName - Regular (Preferred Subfamily Name) + Regular trademark Trademark Some Foundry unitsPerEm diff --git a/tests/data/NestedComponents.ufo/glyphs/_notdef.glif b/tests/data/NestedComponents-Regular.ufo/glyphs/_notdef.glif similarity index 100% rename from tests/data/NestedComponents.ufo/glyphs/_notdef.glif rename to tests/data/NestedComponents-Regular.ufo/glyphs/_notdef.glif diff --git a/tests/data/NestedComponents.ufo/glyphs/a.glif b/tests/data/NestedComponents-Regular.ufo/glyphs/a.glif similarity index 100% rename from tests/data/NestedComponents.ufo/glyphs/a.glif rename to tests/data/NestedComponents-Regular.ufo/glyphs/a.glif diff --git a/tests/data/NestedComponents-Regular.ufo/glyphs/b.glif b/tests/data/NestedComponents-Regular.ufo/glyphs/b.glif new file mode 100644 index 000000000..cfa3215f2 --- /dev/null +++ b/tests/data/NestedComponents-Regular.ufo/glyphs/b.glif @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + com.schriftgestaltung.Glyphs.lastChange + 2020-12-07 11:48:16 +0000 + + + diff --git a/tests/data/NestedComponents.ufo/glyphs/c.glif b/tests/data/NestedComponents-Regular.ufo/glyphs/c.glif similarity index 54% rename from tests/data/NestedComponents.ufo/glyphs/c.glif rename to tests/data/NestedComponents-Regular.ufo/glyphs/c.glif index 416f8bdc4..eba4d273c 100644 --- a/tests/data/NestedComponents.ufo/glyphs/c.glif +++ b/tests/data/NestedComponents-Regular.ufo/glyphs/c.glif @@ -7,6 +7,17 @@ + com.schriftgestaltung.Glyphs.ComponentInfo + + + alignment + -1 + index + 0 + name + a + + com.schriftgestaltung.Glyphs.lastChange 2020-12-07 11:48:18 +0000 diff --git a/tests/data/NestedComponents-Regular.ufo/glyphs/contents.plist b/tests/data/NestedComponents-Regular.ufo/glyphs/contents.plist new file mode 100644 index 000000000..f47769123 --- /dev/null +++ b/tests/data/NestedComponents-Regular.ufo/glyphs/contents.plist @@ -0,0 +1,20 @@ + + + + + .notdef + _notdef.glif + a + a.glif + b + b.glif + c + c.glif + d + d.glif + e + e.glif + space + space.glif + + diff --git a/tests/data/NestedComponents.ufo/glyphs/d.glif b/tests/data/NestedComponents-Regular.ufo/glyphs/d.glif similarity index 93% rename from tests/data/NestedComponents.ufo/glyphs/d.glif rename to tests/data/NestedComponents-Regular.ufo/glyphs/d.glif index ffd1d3461..306720ae2 100644 --- a/tests/data/NestedComponents.ufo/glyphs/d.glif +++ b/tests/data/NestedComponents-Regular.ufo/glyphs/d.glif @@ -3,7 +3,7 @@ - + diff --git a/tests/data/NestedComponents-Regular.ufo/glyphs/e.glif b/tests/data/NestedComponents-Regular.ufo/glyphs/e.glif new file mode 100644 index 000000000..ca489303e --- /dev/null +++ b/tests/data/NestedComponents-Regular.ufo/glyphs/e.glif @@ -0,0 +1,34 @@ + + + + + + + + + + + com.schriftgestaltung.Glyphs.ComponentInfo + + + alignment + -1 + index + 0 + name + c + + + alignment + -1 + index + 1 + name + d + + + com.schriftgestaltung.Glyphs.lastChange + 2020-12-07 11:48:37 +0000 + + + diff --git a/tests/data/NestedComponents.ufo/glyphs/space.glif b/tests/data/NestedComponents-Regular.ufo/glyphs/space.glif similarity index 100% rename from tests/data/NestedComponents.ufo/glyphs/space.glif rename to tests/data/NestedComponents-Regular.ufo/glyphs/space.glif diff --git a/tests/data/NestedComponents-Regular.ufo/layercontents.plist b/tests/data/NestedComponents-Regular.ufo/layercontents.plist new file mode 100644 index 000000000..cf95d3573 --- /dev/null +++ b/tests/data/NestedComponents-Regular.ufo/layercontents.plist @@ -0,0 +1,10 @@ + + + + + + public.default + glyphs + + + diff --git a/tests/data/NestedComponents.ufo/lib.plist b/tests/data/NestedComponents-Regular.ufo/lib.plist similarity index 81% rename from tests/data/NestedComponents.ufo/lib.plist rename to tests/data/NestedComponents-Regular.ufo/lib.plist index 11c81487f..65a43715f 100644 --- a/tests/data/NestedComponents.ufo/lib.plist +++ b/tests/data/NestedComponents-Regular.ufo/lib.plist @@ -2,37 +2,10 @@ - com.schriftgestaltung.DisplayStrings - - e - com.schriftgestaltung.disablesAutomaticAlignment com.schriftgestaltung.font.customParameters - - name - glyphOrder - value - - .notdef - glyph1 - glyph2 - space - a - b - c - d - e - f - g - h - i - j - k - l - - name openTypeGaspRangeRecords @@ -92,19 +65,28 @@ - com.schriftgestaltung.fontMaster.customParameters - + com.schriftgestaltung.font.userData + + GSDimensionPlugin.Dimensions - name - underlineThickness - value - 20 + master01 + + + com.schriftgestaltung.fontMaster.customParameters + name - underlinePosition + Alignment Zones value - -200 + + + pos + -260.0 + size + 10.0 + + com.schriftgestaltung.fontMasterID @@ -130,6 +112,8 @@ com.schriftgestaltung.useNiceNames + com.schriftgestaltung.weightValue + 400 public.glyphOrder .notdef diff --git a/tests/data/NestedComponents-Regular.ufo/metainfo.plist b/tests/data/NestedComponents-Regular.ufo/metainfo.plist new file mode 100644 index 000000000..74e4b3b4f --- /dev/null +++ b/tests/data/NestedComponents-Regular.ufo/metainfo.plist @@ -0,0 +1,10 @@ + + + + + creator + com.schriftgestaltung.GlyphsUFOExport + formatVersion + 3 + + diff --git a/tests/data/NestedComponents-flat.ttx b/tests/data/NestedComponents-flat.ttx deleted file mode 100644 index 8b7168e27..000000000 --- a/tests/data/NestedComponents-flat.ttx +++ /dev/null @@ -1,356 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Copyright © Some Foundry. - - - Some Font Regular (Style Map Family Name) - - - Regular - - - OpenType name Table Unique ID - - - Some Font (Preferred Family Name) Regular (Preferred Subfamily Name) - - - OpenType name Table Version - - - SomeFont-RegularPostscriptFontName - - - Trademark Some Foundry - - - Some Foundry - - - Some Designer - - - Some Font by Some Designer for Some Foundry. - - - http://somefoundry.com - - - http://somedesigner.com - - - License info for Some Foundry. - - - http://somefoundry.com/license - - - Some Font (Preferred Family Name) - - - Regular (Preferred Subfamily Name) - - - Some Font Regular (Compatible Full Name) - - - Sample Text for Some Font. - - - Some Font (WWS Family Name) - - - Regular (WWS Subfamily Name) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/data/NestedComponents.ttx b/tests/data/NestedComponents.ttx deleted file mode 100644 index 792c6bf9e..000000000 --- a/tests/data/NestedComponents.ttx +++ /dev/null @@ -1,355 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Copyright © Some Foundry. - - - Some Font Regular (Style Map Family Name) - - - Regular - - - OpenType name Table Unique ID - - - Some Font (Preferred Family Name) Regular (Preferred Subfamily Name) - - - OpenType name Table Version - - - SomeFont-RegularPostscriptFontName - - - Trademark Some Foundry - - - Some Foundry - - - Some Designer - - - Some Font by Some Designer for Some Foundry. - - - http://somefoundry.com - - - http://somedesigner.com - - - License info for Some Foundry. - - - http://somefoundry.com/license - - - Some Font (Preferred Family Name) - - - Regular (Preferred Subfamily Name) - - - Some Font Regular (Compatible Full Name) - - - Sample Text for Some Font. - - - Some Font (WWS Family Name) - - - Regular (WWS Subfamily Name) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/data/NestedComponents.ufo/glyphs/b.glif b/tests/data/NestedComponents.ufo/glyphs/b.glif deleted file mode 100644 index e1c7ad72f..000000000 --- a/tests/data/NestedComponents.ufo/glyphs/b.glif +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - com.schriftgestaltung.Glyphs.lastChange - 2020-12-07 11:48:16 +0000 - - - diff --git a/tests/data/NestedComponents.ufo/glyphs/e.glif b/tests/data/NestedComponents.ufo/glyphs/e.glif deleted file mode 100644 index 329315f69..000000000 --- a/tests/data/NestedComponents.ufo/glyphs/e.glif +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - com.schriftgestaltung.Glyphs.lastChange - 2020-12-07 11:48:37 +0000 - - - diff --git a/tests/integration_test.py b/tests/integration_test.py index 6c715b4f0..e80ae9e5e 100644 --- a/tests/integration_test.py +++ b/tests/integration_test.py @@ -119,15 +119,22 @@ def test_removeOverlaps_pathops(self, testufo): ttf = compileTTF(testufo, removeOverlaps=True, overlapsBackend="pathops") expectTTX(ttf, "TestFont-NoOverlaps-TTF-pathops.ttx") - def test_nestedComponents_noFlatten(self, FontClass): - ufo = FontClass(getpath("NestedComponents.ufo")) + def test_nestedComponents(self, FontClass): + ufo = FontClass(getpath("NestedComponents-Regular.ufo")) ttf = compileTTF(ufo) - expectTTX(ttf, "NestedComponents.ttx") - - def test_nestedComponents_flatten(self, FontClass): - ufo = FontClass(getpath("NestedComponents.ufo")) + assert ttf["maxp"].maxComponentDepth != 1 ttf = compileTTF(ufo, flattenComponents=True) - expectTTX(ttf, "NestedComponents-flat.ttx") + assert ttf["maxp"].maxComponentDepth == 1 + + def test_nestedComponents_interpolatable(self, FontClass): + ufos = [ FontClass(getpath("NestedComponents-Regular.ufo")), + FontClass(getpath("NestedComponents-Bold.ufo")) ] + ttfs = compileInterpolatableTTFs(ufos) + for ttf in ttfs: + assert ttf["maxp"].maxComponentDepth != 1 + ttfs = compileInterpolatableTTFs(ufos, flattenComponents=True) + for ttf in ttfs: + assert ttf["maxp"].maxComponentDepth == 1 def test_interpolatableTTFs_lazy(self, FontClass): # two same UFOs **must** be interpolatable From b0c967316e796c79d05f805f8d4576a15da18f91 Mon Sep 17 00:00:00 2001 From: Simon Cozens Date: Thu, 10 Dec 2020 10:02:02 +0000 Subject: [PATCH 8/8] flattenComponents=None->False --- Lib/ufo2ft/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Lib/ufo2ft/__init__.py b/Lib/ufo2ft/__init__.py index ab93b5a33..d7e382c6b 100644 --- a/Lib/ufo2ft/__init__.py +++ b/Lib/ufo2ft/__init__.py @@ -172,7 +172,7 @@ def compileTTF( rememberCurveType=True, removeOverlaps=False, overlapsBackend=None, - flattenComponents=None, + flattenComponents=False, inplace=False, layerName=None, skipExportGlyphs=None, @@ -252,7 +252,7 @@ def compileInterpolatableTTFs( useProductionNames=None, cubicConversionError=None, reverseDirection=True, - flattenComponents=None, + flattenComponents=False, inplace=False, layerNames=None, skipExportGlyphs=None, @@ -360,7 +360,7 @@ def compileInterpolatableTTFsFromDS( useProductionNames=None, cubicConversionError=None, reverseDirection=True, - flattenComponents=None, + flattenComponents=False, inplace=False, debugFeatureFile=None, notdefGlyph=None, @@ -577,7 +577,7 @@ def compileVariableTTF( reverseDirection=True, excludeVariationTables=(), optimizeGvar=True, - flattenComponents=None, + flattenComponents=False, inplace=False, debugFeatureFile=None, notdefGlyph=None,