Skip to content

Commit

Permalink
Merge pull request #627 from googlefonts/variable-colr
Browse files Browse the repository at this point in the history
disable COLR layer reuse for interpolatable masters when building variable fonts
  • Loading branch information
anthrotype authored Jul 6, 2022
2 parents 133c126 + c57e29a commit e701144
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
7 changes: 7 additions & 0 deletions Lib/ufo2ft/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def call_postprocessor(otf, ufo, glyphSet, *, postProcessorClass, **kwargs):
skipExportGlyphs=None,
debugFeatureFile=None,
notdefGlyph=None,
colrLayerReuse=True,
)

compileOTF_args = {
Expand Down Expand Up @@ -258,6 +259,7 @@ def compileTTF(ufo, **kwargs):
reverseDirection=True,
flattenComponents=False,
layerNames=None,
colrLayerReuse=False,
),
}

Expand Down Expand Up @@ -392,6 +394,7 @@ def compileInterpolatableTTFsFromDS(designSpaceDoc, **kwargs):
featureCompilerClass=None,
roundTolerance=None,
optimizeCFF=CFFOptimization.NONE,
colrLayerReuse=False,
),
}

Expand Down Expand Up @@ -582,6 +585,7 @@ def compileVariableTTFs(designSpaceDoc: DesignSpaceDocument, **kwargs):
optimizeGvar = kwargs.pop("optimizeGvar")
excludeVariationTables = kwargs.pop("excludeVariationTables")
variableFontNames = kwargs.pop("variableFontNames")
colrLayerReuse = kwargs.pop("colrLayerReuse")

# Pop inplace because we'll make a copy at this level so deeper functions
# don't need to worry
Expand All @@ -603,6 +607,7 @@ def compileVariableTTFs(designSpaceDoc: DesignSpaceDocument, **kwargs):
exclude=excludeVariationTables,
optimize=optimizeGvar,
skip_vf=lambda vf_name: variableFontNames and vf_name not in variableFontNames,
colr_layer_reuse=colrLayerReuse,
)

for vfName, varfont in list(vfNameToTTFont.items()):
Expand Down Expand Up @@ -692,6 +697,7 @@ def compileVariableCFF2s(designSpaceDoc, **kwargs):
excludeVariationTables = kwargs.pop("excludeVariationTables")
optimizeCFF = CFFOptimization(kwargs.pop("optimizeCFF"))
variableFontNames = kwargs.pop("variableFontNames")
colrLayerReuse = kwargs.pop("colrLayerReuse")

# Pop inplace because we'll make a copy at this level so deeper functions
# don't need to worry
Expand All @@ -716,6 +722,7 @@ def compileVariableCFF2s(designSpaceDoc, **kwargs):
# https://github.com/fonttools/fonttools/pull/1979
optimize=optimizeCFF >= CFFOptimization.SPECIALIZE,
skip_vf=lambda vf_name: variableFontNames and vf_name not in variableFontNames,
colr_layer_reuse=colrLayerReuse,
)

for vfName, varfont in list(vfNameToTTFont.items()):
Expand Down
2 changes: 1 addition & 1 deletion Lib/ufo2ft/featureWriters/markFeatureWriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ def _groupAttachments(self, attachments):
# We keep the NamedAnchor if the markClass is allowed in the
# current lookup.
def include(anchor):
return anchor.markClass.name in markClasses
return anchor.markClass.name in markClasses # noqa: B023

filteredAttachment = attachment.filter(include)
if filteredAttachment:
Expand Down
10 changes: 9 additions & 1 deletion Lib/ufo2ft/outlineCompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,13 @@ class BaseOutlineCompiler:
)

def __init__(
self, font, glyphSet=None, glyphOrder=None, tables=None, notdefGlyph=None
self,
font,
glyphSet=None,
glyphOrder=None,
tables=None,
notdefGlyph=None,
colrLayerReuse=True,
):
self.ufo = font
# use the previously filtered glyphSet, if any
Expand All @@ -110,6 +116,7 @@ def __init__(
self.unicodeToGlyphNameMapping = self.makeUnicodeToGlyphNameMapping()
if tables is not None:
self.tables = tables
self.colrLayerReuse = colrLayerReuse
# cached values defined later on
self._glyphBoundingBoxes = None
self._fontBoundingBox = None
Expand Down Expand Up @@ -967,6 +974,7 @@ def setupTable_COLR(self):
layerInfo,
glyphMap=glyphMap,
clipBoxes=clipBoxes,
allowLayerReuse=self.colrLayerReuse,
)

def setupTable_CPAL(self):
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
fonttools[lxml,ufo]==4.33.3
fonttools[lxml,ufo]==4.34.0
defcon==0.10.0
cu2qu==1.6.7.post1
compreffor==0.5.1.post1
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
setup_requires=pytest_runner + wheel + ["setuptools_scm"],
tests_require=["pytest>=2.8"],
install_requires=[
"fonttools[ufo]>=4.33.3",
"fonttools[ufo]>=4.34.0",
"cu2qu>=1.6.7",
"cffsubr>=0.2.8",
"booleanOperations>=0.9.0",
Expand Down

0 comments on commit e701144

Please sign in to comment.