summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorJames Godfrey-Kittle <jamesgk@google.com>2015-02-21 13:13:38 -0800
committerJames Godfrey-Kittle <jamesgk@google.com>2015-04-16 12:16:30 -0700
commit30193f337af2d2a1668658e2c5c456b1abd2586a (patch)
tree68e0840d6497d38989baac00f800f1407849610f /scripts
parenta9399ccfa784268eece38fa946bf9f531f2db306 (diff)
Set unicode values for generated glyphs.
This is necessary for the FDK to include these new glyphs in the output OTF's cmap.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/lib/fontbuild/Build.py17
-rw-r--r--scripts/lib/fontbuild/generateGlyph.py8
2 files changed, 19 insertions, 6 deletions
diff --git a/scripts/lib/fontbuild/Build.py b/scripts/lib/fontbuild/Build.py
index f96e487..3682e3d 100644
--- a/scripts/lib/fontbuild/Build.py
+++ b/scripts/lib/fontbuild/Build.py
@@ -32,9 +32,16 @@ class FontProject:
self.ot_kerningclasses = open(self.basedir + "/" + self.config.get("res","ot_kerningclassesfile")).read()
self.ot_features = open(self.basedir + "/" + self.config.get("res","ot_featuresfile")).read()
adobeGlyphList = open(self.basedir + "/" + self.config.get("res", "agl_glyphlistfile")).readlines()
- self.adobeGlyphList = set([line.split(";")[1] for line in adobeGlyphList if not line.startswith("#")])
+ self.adobeGlyphList = dict([line.split(";") for line in adobeGlyphList if not line.startswith("#")])
- self.builddir = "out"
+ # map exceptional glyph names in Roboto to names in the AGL
+ roboNames = (
+ ('Obar', 'Ocenteredtilde'), ('obar', 'obarred'),
+ ('eturn', 'eturned'), ('Iota1', 'Iotaafrican'))
+ for roboName, aglName in roboNames:
+ self.adobeGlyphList[roboName] = self.adobeGlyphList[aglName]
+
+ self.builddir = "out/v2"
self.decompose = self.config.get("glyphs","decompose").split()
self.predecompose = self.config.get("glyphs","predecompose").split()
self.lessItalic = self.config.get("glyphs","lessitalic").split()
@@ -134,7 +141,7 @@ class FontProject:
decomposeGlyph(f[gname])
log(">> Generating glyphs")
- generateGlyphs(f, self.diacriticList)
+ generateGlyphs(f, self.diacriticList, self.adobeGlyphList)
log(">> Copying features")
readGlyphClasses(f, self.ot_classes)
readFeatureFile(f, self.basefont.features.text)
@@ -225,12 +232,12 @@ def log(msg):
print msg
-def generateGlyphs(f, glyphNames):
+def generateGlyphs(f, glyphNames, glyphList={}):
log(">> Generating diacritics")
glyphnames = [gname for gname in glyphNames if not gname.startswith("#") and gname != ""]
for glyphName in glyphNames:
- generateGlyph(f, glyphName)
+ generateGlyph(f, glyphName, glyphList)
def cleanCurves(f):
#TODO(jamesgk) remove calls to removeGlyphOverlap if we decide to use AFDKO
diff --git a/scripts/lib/fontbuild/generateGlyph.py b/scripts/lib/fontbuild/generateGlyph.py
index 0bf25a1..4794fd8 100644
--- a/scripts/lib/fontbuild/generateGlyph.py
+++ b/scripts/lib/fontbuild/generateGlyph.py
@@ -16,13 +16,15 @@ def parseComposite(composite):
return (glyphName, baseName, accentNames, offset)
-def generateGlyph(f,gname):
+def generateGlyph(f,gname,glyphList={}):
glyphName, baseName, accentNames, offset = parseComposite(gname)
+
if baseName.find("_") != -1:
g = f.newGlyph(glyphName)
for componentName in baseName.split("_"):
g.appendComponent(componentName, (g.width, 0))
g.width += f[componentName].width
+
else:
if not f.has_key(glyphName):
try:
@@ -40,3 +42,7 @@ def generateGlyph(f,gname):
else:
print ("Existing glyph '%s' found in font, ignoring composition "
"rule '%s'" % (glyphName, gname))
+
+ # try to ensure every glyph has a unicode value -- used by FDK to make OTFs
+ if glyphName in glyphList:
+ f[glyphName].unicode = int(glyphList[glyphName], 16)