Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only decompose glyphs with reflected components #171

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 7 additions & 13 deletions misc/fontbuild
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,9 @@ def fatal(msg):



def composedGlyphIsNonTrivial(g, yAxisIsNonTrivial=False):
# A non-trivial glyph is one that is composed from either multiple
# components or that uses component transformations.
# If yAxisIsNonTrivial is true, then any transformation over the Y axis
# is be considered non-trivial.
def composedGlyphIsNonTrivial(g):
# A non-trivial glyph is one that uses reflecting component transformations.
if g.components and len(g.components) > 0:
if len(g.components) > 1:
return True
for c in g.components:
# has non-trivial transformation? (i.e. scaled)
# Example of optimally trivial transformation:
Expand All @@ -74,10 +69,10 @@ def composedGlyphIsNonTrivial(g, yAxisIsNonTrivial=False):
# (-1.0, 0, 0.3311, 1, 1464.0, 0) flipped x axis, sheered and offset
#
xScale, xyScale, yxScale, yScale, xOffset, yOffset = c.transformation
if xScale != 1 or xyScale != 0 or yxScale != 0 or yScale != 1:
return True
if yAxisIsNonTrivial and yOffset != 0:
# If glyph is reflected along x or y axes, it won't slant well.
if xScale < 0 or yScale < 0:
return True

return False


Expand Down Expand Up @@ -157,7 +152,7 @@ class VarFontProject(FontProject):
**kwargs
):
"""Build OpenType binaries with interpolatable outlines."""
# We decompose any glyph with two or more components to make sure
# We decompose any glyph with reflected components to make sure
# that fontTools varLib is able to produce properly-slanting interpolation.

self._load_designspace_sources(designspace)
Expand All @@ -179,12 +174,11 @@ class VarFontProject(FontProject):
ufo.info.openTypeNamePreferredFamilyName =\
ufo.info.openTypeNamePreferredFamilyName.replace('Inter', self.familyName)
updateFontVersion(ufo)
isItalic = ufo.info.italicAngle != 0
ufoname = basename(ufo.path)

for g in ufo:
directives = findGlyphDirectives(g)
if g.components and composedGlyphIsNonTrivial(g, yAxisIsNonTrivial=isItalic):
if g.components and composedGlyphIsNonTrivial(g):
decomposeGlyphs.add(g.name)
if 'removeoverlap' in directives:
if g.components and len(g.components) > 0:
Expand Down