From 37fd492bbd8adf4d79ce92d46f071db8d08590a7 Mon Sep 17 00:00:00 2001 From: Jany Belluz Date: Fri, 24 Sep 2021 18:02:34 +0100 Subject: [PATCH 1/2] [config] Don't optimize GPOS when compiling masters for a VF --- Lib/ufo2ft/__init__.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Lib/ufo2ft/__init__.py b/Lib/ufo2ft/__init__.py index 6c7411199..0625a789d 100644 --- a/Lib/ufo2ft/__init__.py +++ b/Lib/ufo2ft/__init__.py @@ -531,6 +531,15 @@ def compileVariableTTF(designSpaceDoc, **kwargs): # No need to post-process intermediate fonts. postProcessorClass=None, ), + "config": { + **kwargs.get("config", {}), + # Whichever level of GPOS optimization the user has chosen, we + # know here that the optimization would be pointless, because + # the interpolatable OTFs will be merged by varLib, which + # un-does the optimization, then re-optimized differently after + # the merge. + "otlLib.optimize.gpos.mode": 0, + }, } ) @@ -588,6 +597,15 @@ def compileVariableCFF2(designSpaceDoc, **kwargs): # No need to post-process intermediate fonts. postProcessorClass=None, ), + "config": { + **kwargs.get("config", {}), + # Whichever level of GPOS optimization the user has chosen, we + # know here that the optimization would be pointless, because + # the interpolatable OTFs will be merged by varLib, which + # un-does the optimization, then re-optimized differently after + # the merge. + "otlLib.optimize.gpos.mode": 0, + }, } ) From ffc748a6c9c5eade82ce2ec5cd8830a28c8876ba Mon Sep 17 00:00:00 2001 From: Jany Belluz Date: Fri, 24 Sep 2021 18:19:24 +0100 Subject: [PATCH 2/2] [config] WIP Pass config through to fontTools --- Lib/ufo2ft/__init__.py | 1 + Lib/ufo2ft/outlineCompiler.py | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Lib/ufo2ft/__init__.py b/Lib/ufo2ft/__init__.py index 0625a789d..a0dbac4df 100644 --- a/Lib/ufo2ft/__init__.py +++ b/Lib/ufo2ft/__init__.py @@ -79,6 +79,7 @@ def call_postprocessor(otf, ufo, glyphSet, kwargs, **overrides): skipExportGlyphs=None, debugFeatureFile=None, notdefGlyph=None, + config={}, ) compileOTF_args = { diff --git a/Lib/ufo2ft/outlineCompiler.py b/Lib/ufo2ft/outlineCompiler.py index 112f05c2f..7b8fa0a9d 100644 --- a/Lib/ufo2ft/outlineCompiler.py +++ b/Lib/ufo2ft/outlineCompiler.py @@ -119,12 +119,13 @@ def __init__( self._glyphBoundingBoxes = None self._fontBoundingBox = None self._compiledGlyphs = None + self._config = kwargs.get("config", {}) def compile(self): """ Compile the OpenType binary. """ - self.otf = TTFont(sfntVersion=self.sfntVersion) + self.otf = TTFont(sfntVersion=self.sfntVersion, config=self._config) # only compile vertical metrics tables if vhea metrics are defined vertical_metrics = [ @@ -1101,6 +1102,7 @@ def __init__( glyphOrder=glyphOrder, tables=tables, notdefGlyph=notdefGlyph, + **kwargs, ) self.optimizeCFF = optimizeCFF self._defaultAndNominalWidths = None