summaryrefslogtreecommitdiff
path: root/scripts/lib/fontbuild/kerning.py
diff options
context:
space:
mode:
authorChristian Robertson <robertsonc@google.com>2014-05-19 16:09:20 -0700
committerChristian Robertson <robertsonc@google.com>2014-05-19 16:09:20 -0700
commit7051939fa74b5f8f453be605f5dc3b4c23e1d1d9 (patch)
tree65cb31b34a64b2b07f9f6fd1bcb58d9a4945a92d /scripts/lib/fontbuild/kerning.py
Importing Roboto 2.0
Diffstat (limited to 'scripts/lib/fontbuild/kerning.py')
-rwxr-xr-xscripts/lib/fontbuild/kerning.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/scripts/lib/fontbuild/kerning.py b/scripts/lib/fontbuild/kerning.py
new file mode 100755
index 0000000..cdece40
--- /dev/null
+++ b/scripts/lib/fontbuild/kerning.py
@@ -0,0 +1,26 @@
+import re
+from FL import *
+
+def markKernClassesLR(f):
+ for i in range(len(f.classes)):
+ classname = f.classes[i].split(':', 1).pop(0).strip()
+ if classname.startswith('_'):
+ l = 0
+ r = 0
+ if classname.endswith('_L'):
+ l = 1
+ elif classname.endswith('_R'):
+ r = 1
+ elif classname.endswith('_LR'):
+ l = 1
+ r = 1
+ f.SetClassFlags(i, l, r)
+ fl.UpdateFont()
+
+def generateFLKernClassesFromOTString(f,classString):
+ classString.replace("\r","\n")
+ rx = re.compile(r"@(_[\w]+)\s*=\s*\[\s*(\w+?)\s+(.*?)\]\s*;")
+ classes = ["%s : %s' %s" %(m[0],m[1],m[2]) for m in rx.findall(classString)]
+ f.classes = classes
+ markKernClassesLR(f)
+