diff options
Diffstat (limited to 'misc/fontbuild')
-rwxr-xr-x | misc/fontbuild | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/misc/fontbuild b/misc/fontbuild index 1d4a8d801..075886a7e 100755 --- a/misc/fontbuild +++ b/misc/fontbuild @@ -58,26 +58,22 @@ 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: # (1, 0, 0, 1, 0, 0) no scale or offset # Example of scaled transformation matrix: # (-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: + # + xScale = c.transformation[0] + yScale = c.transformation[3] + # If glyph is reflected along x or y axes, it won't slant well. + if xScale < 0 or yScale < 0: return True + return False @@ -157,7 +153,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) @@ -179,12 +175,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: @@ -247,7 +242,7 @@ def updateFontVersion(font, dummy=False): # setFontInfo patches font.info -# +# def setFontInfo(font, weight): # # For UFO3 names, see @@ -487,7 +482,7 @@ class Main(object): if outfilename is None or outfilename == '': outfilename = os.path.splitext(basename(args.srcfile))[0] + '.otf' log.info('setting --output %r' % outfilename) - + # build formats list from filename extension formats = [] # for outfilename in args.outputs: @@ -550,7 +545,7 @@ class Main(object): success = False if len(otssan_res) == 0: otssan_res = 'error' - + if success: os.unlink(tmpfile) else: @@ -732,7 +727,7 @@ class Main(object): else: # name "Black" => "black" source.name = source.styleName.lower().replace(' ', '') - + source.path = ufo_path weight = int(source.location['Weight']) @@ -840,11 +835,11 @@ class Main(object): # clear anchors for g in font: g.clearAnchors() - + # update font info weight = instance_weight[basename(font.path)] setFontInfo(font, weight) - + font.save() @@ -875,7 +870,7 @@ class Main(object): argparser.add_argument('files', metavar='<file>', nargs='+', help='Font files') - + args = argparser.parse_args(argv) q = Queue() |