summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Godfrey-Kittle <jamesgk@google.com>2015-04-10 12:42:35 -0700
committerJames Godfrey-Kittle <jamesgk@google.com>2015-04-16 12:16:34 -0700
commit931ed8a2df0e790e980785d2e0da9a7de738c8ea (patch)
tree7c3824b9d78f3369d3bc2bc359fc02aa8f9da166
parente6d114559a020a29e0f64cfd674de401609d7083 (diff)
Update scripts to use external kerning rules.
-rw-r--r--scripts/lib/fontbuild/Build.py9
-rwxr-xr-xscripts/lib/fontbuild/features.py8
2 files changed, 15 insertions, 2 deletions
diff --git a/scripts/lib/fontbuild/Build.py b/scripts/lib/fontbuild/Build.py
index 0e1e35d..b7b3263 100644
--- a/scripts/lib/fontbuild/Build.py
+++ b/scripts/lib/fontbuild/Build.py
@@ -30,6 +30,7 @@ class FontProject:
self.ot_classes = open(self.basedir + "/" + self.config.get("res","ot_classesfile")).read()
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()
+ self.ot_kerningfeatures = self.basedir + "/" + self.config.get("res","ot_kerningfeaturesdir")
adobeGlyphList = open(self.basedir + "/" + self.config.get("res", "agl_glyphlistfile")).readlines()
self.adobeGlyphList = dict([line.split(";") for line in adobeGlyphList if not line.startswith("#")])
@@ -156,6 +157,14 @@ class FontProject:
if kern:
log(">> Generating kern classes")
readFeatureFile(f, self.ot_kerningclasses)
+ weight = f.info.styleName.split()[0]
+ if weight in ["Light", "Italic"]:
+ weight = "Regular"
+ elif weight in ["Medium", "Black"]:
+ weight = "Bold"
+ feature_path = os.path.join(
+ self.ot_kerningfeatures, "Roboto-%s.fea" % weight)
+ readFeatureFile(f, open(feature_path).read(), prepend=False)
log(">> Generating font files")
GenerateFeature_mark(f)
diff --git a/scripts/lib/fontbuild/features.py b/scripts/lib/fontbuild/features.py
index 4e128a5..e26954b 100755
--- a/scripts/lib/fontbuild/features.py
+++ b/scripts/lib/fontbuild/features.py
@@ -193,10 +193,14 @@ def updateFeature(font, name, value):
font.features.text += "\n" + value
-def readFeatureFile(font, text):
+def readFeatureFile(font, text, prepend=True):
"""Incorporate valid definitions from feature text into font."""
writer = FilterFeatureWriter(set(font.keys()))
- parser.parseFeatures(writer, text + font.features.text)
+ if prepend:
+ text += font.features.text
+ else:
+ text = font.features.text + text
+ parser.parseFeatures(writer, text)
font.features.text = writer.write()