summaryrefslogtreecommitdiff
path: root/misc/fontbuildlib/builder.py
diff options
context:
space:
mode:
authorRasmus Andersson <rasmus@notion.se>2020-08-19 23:54:30 +0300
committerRasmus Andersson <rasmus@notion.se>2020-08-19 23:54:30 +0300
commit7d70535c01803b9c734147acb3049a74875f6356 (patch)
tree13175f4e2ba7f64cb7547cd88db3f8d6a5531ca8 /misc/fontbuildlib/builder.py
parent05e3a4c7747886ffe8e89af9c67d20f63da0a8b7 (diff)
downloadinter-7d70535c01803b9c734147acb3049a74875f6356.tar.xz
Fixes an issue with rendering on Windows with ClearType by decomposing any components which use non-trivial transformations like rotation or shear. This increases font size a bit but not to any worrying degree. Closes #251
Diffstat (limited to 'misc/fontbuildlib/builder.py')
-rw-r--r--misc/fontbuildlib/builder.py29
1 files changed, 20 insertions, 9 deletions
diff --git a/misc/fontbuildlib/builder.py b/misc/fontbuildlib/builder.py
index da769769c..bef295d13 100644
--- a/misc/fontbuildlib/builder.py
+++ b/misc/fontbuildlib/builder.py
@@ -27,6 +27,14 @@ class FontBuilder:
# update version to actual, real version. Must come after any call to setFontInfo.
updateFontVersion(ufo, dummy=False, isVF=False)
+ # decompose some glyphs
+ glyphNamesToDecompose = set()
+ for g in ufo:
+ directives = findGlyphDirectives(g.note)
+ if 'decompose' in directives or (g.components and not composedGlyphIsTrivial(g)):
+ glyphNamesToDecompose.add(g.name)
+ self._decompose([ufo], glyphNamesToDecompose)
+
compilerOptions = dict(
useProductionNames=True,
inplace=True, # avoid extra copy
@@ -89,9 +97,16 @@ class FontBuilder:
font.save(outputFilename)
+ def _decompose(self, ufos, glyphNamesToDecompose):
+ if glyphNamesToDecompose:
+ if log.isEnabledFor(logging.DEBUG):
+ log.debug('Decomposing glyphs:\n %s', "\n ".join(glyphNamesToDecompose))
+ elif log.isEnabledFor(logging.INFO):
+ log.info('Decomposing %d glyphs', len(glyphNamesToDecompose))
+ decomposeGlyphs(ufos, glyphNamesToDecompose)
+
- @staticmethod
- def _loadDesignspace(designspace):
+ def _loadDesignspace(self, designspace):
log.info("loading designspace sources")
if isinstance(designspace, str):
designspace = DesignSpaceDocument.fromfile(designspace)
@@ -120,6 +135,8 @@ class FontBuilder:
for ufo in masters:
for g in ufo:
directives = findGlyphDirectives(g.note)
+ if g.name == 'parenright':
+ print("parenright directives:", repr(directives))
if 'decompose' in directives or (g.components and not composedGlyphIsTrivial(g)):
glyphNamesToDecompose.add(g.name)
if 'removeoverlap' in directives:
@@ -127,13 +144,7 @@ class FontBuilder:
glyphNamesToDecompose.add(g.name)
glyphsToRemoveOverlaps.add(g)
- # decompose
- if glyphNamesToDecompose:
- if log.isEnabledFor(logging.DEBUG):
- log.debug('Decomposing glyphs:\n %s', "\n ".join(glyphNamesToDecompose))
- elif log.isEnabledFor(logging.INFO):
- log.info('Decomposing %d glyphs', len(glyphNamesToDecompose))
- decomposeGlyphs(masters, glyphNamesToDecompose)
+ self._decompose(masters, glyphNamesToDecompose)
# remove overlaps
if glyphsToRemoveOverlaps: