fontbuild: remove component condition in composedGlyphIsNonTrivial

This commit is contained in:
Rasmus Andersson 2019-07-18 14:04:29 -07:00
parent b2b8c14660
commit a96f0d50f2

View file

@ -61,16 +61,15 @@ def fatal(msg):
def composedGlyphIsNonTrivial(g): def composedGlyphIsNonTrivial(g):
# A non-trivial glyph is one that uses reflecting component transformations. # A non-trivial glyph is one that uses reflecting component transformations.
if g.components and len(g.components) > 0: if g.components and len(g.components) > 0:
if len(g.components) > 1:
return True
for c in g.components: for c in g.components:
# has non-trivial transformation? (i.e. scaled) # has non-trivial transformation? (i.e. scaled)
# Example of optimally trivial transformation: # Example of optimally trivial transformation:
# (1, 0, 0, 1, 0, 0) no scale or offset # (1, 0, 0, 1, 0, 0) no scale or offset
# Example of scaled transformation matrix: # Example of scaled transformation matrix:
# (-1.0, 0, 0.3311, 1, 1464.0, 0) flipped x axis, sheered and offset # (-1.0, 0, 0.3311, 1, 1464.0, 0) flipped x axis, sheered and offset
# #
xScale, xyScale, yxScale, yScale, xOffset, yOffset = c.transformation xScale = c.transformation[0]
yScale = c.transformation[3]
# If glyph is reflected along x or y axes, it won't slant well. # If glyph is reflected along x or y axes, it won't slant well.
if xScale < 0 or yScale < 0: if xScale < 0 or yScale < 0:
return True return True
@ -177,7 +176,7 @@ class VarFontProject(FontProject):
ufo.info.openTypeNamePreferredFamilyName.replace('Inter', self.familyName) ufo.info.openTypeNamePreferredFamilyName.replace('Inter', self.familyName)
updateFontVersion(ufo) updateFontVersion(ufo)
ufoname = basename(ufo.path) ufoname = basename(ufo.path)
for g in ufo: for g in ufo:
directives = findGlyphDirectives(g) directives = findGlyphDirectives(g)
if g.components and composedGlyphIsNonTrivial(g): if g.components and composedGlyphIsNonTrivial(g):
@ -243,7 +242,7 @@ def updateFontVersion(font, dummy=False):
# setFontInfo patches font.info # setFontInfo patches font.info
# #
def setFontInfo(font, weight): def setFontInfo(font, weight):
# #
# For UFO3 names, see # For UFO3 names, see
@ -483,7 +482,7 @@ class Main(object):
if outfilename is None or outfilename == '': if outfilename is None or outfilename == '':
outfilename = os.path.splitext(basename(args.srcfile))[0] + '.otf' outfilename = os.path.splitext(basename(args.srcfile))[0] + '.otf'
log.info('setting --output %r' % outfilename) log.info('setting --output %r' % outfilename)
# build formats list from filename extension # build formats list from filename extension
formats = [] formats = []
# for outfilename in args.outputs: # for outfilename in args.outputs:
@ -546,7 +545,7 @@ class Main(object):
success = False success = False
if len(otssan_res) == 0: if len(otssan_res) == 0:
otssan_res = 'error' otssan_res = 'error'
if success: if success:
os.unlink(tmpfile) os.unlink(tmpfile)
else: else:
@ -728,7 +727,7 @@ class Main(object):
else: else:
# name "Black" => "black" # name "Black" => "black"
source.name = source.styleName.lower().replace(' ', '') source.name = source.styleName.lower().replace(' ', '')
source.path = ufo_path source.path = ufo_path
weight = int(source.location['Weight']) weight = int(source.location['Weight'])
@ -836,11 +835,11 @@ class Main(object):
# clear anchors # clear anchors
for g in font: for g in font:
g.clearAnchors() g.clearAnchors()
# update font info # update font info
weight = instance_weight[basename(font.path)] weight = instance_weight[basename(font.path)]
setFontInfo(font, weight) setFontInfo(font, weight)
font.save() font.save()
@ -871,7 +870,7 @@ class Main(object):
argparser.add_argument('files', metavar='<file>', nargs='+', argparser.add_argument('files', metavar='<file>', nargs='+',
help='Font files') help='Font files')
args = argparser.parse_args(argv) args = argparser.parse_args(argv)
q = Queue() q = Queue()