summaryrefslogtreecommitdiff
path: root/scripts/lib/fontbuild/Build.py
diff options
context:
space:
mode:
authorJames Godfrey-Kittle <jamesgk@google.com>2015-03-02 18:24:51 -0800
committerJames Godfrey-Kittle <jamesgk@google.com>2015-04-16 12:16:31 -0700
commit420669657a291fe4f77521dc2c39f84464f74501 (patch)
tree6d149bfe6b80a1bce03f483dd0d72cb86021add0 /scripts/lib/fontbuild/Build.py
parent0370954d363233e17b2ecd598894f9e50c6bc831 (diff)
Move saveOTF module into main build script.
saveOTF has become small enough that it probably shouldn't be a separate module.
Diffstat (limited to 'scripts/lib/fontbuild/Build.py')
-rw-r--r--scripts/lib/fontbuild/Build.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/scripts/lib/fontbuild/Build.py b/scripts/lib/fontbuild/Build.py
index 5e9c34c..a3c7d54 100644
--- a/scripts/lib/fontbuild/Build.py
+++ b/scripts/lib/fontbuild/Build.py
@@ -11,7 +11,6 @@ from fontbuild.markFeature import GenerateFeature_mark
from fontbuild.mkmkFeature import GenerateFeature_mkmk
from fontbuild.decomposeGlyph import decomposeGlyph
from fontbuild.removeGlyphOverlap import removeGlyphOverlap
-from fontbuild.saveOTF import saveOTF
import ConfigParser
import os
@@ -264,3 +263,25 @@ def deleteGlyphs(f, deleteList):
for name in deleteList:
if f.has_key(name):
f.removeGlyph(name)
+
+
+def saveOTF(font, destFile, autohint=False):
+ """Save a RoboFab font as an OTF binary using ufo2fdk."""
+
+ from ufo2fdk import OTFCompiler
+
+ # glyphs with multiple unicode values must be split up, due to FontTool's
+ # use of a name -> UV dictionary during cmap compilation
+ for glyph in font:
+ if len(glyph.unicodes) > 1:
+ newUV = glyph.unicodes.pop()
+ newGlyph = font.newGlyph("uni%04X" % newUV)
+ newGlyph.appendComponent(glyph.name)
+ newGlyph.unicode = newUV
+ newGlyph.width = glyph.width
+
+ compiler = OTFCompiler()
+ reports = compiler.compile(font, destFile, autohint=autohint)
+ if autohint:
+ print reports["autohint"]
+ print reports["makeotf"]