summaryrefslogtreecommitdiff
path: root/scripts/lib/fontbuild/kerning.py
diff options
context:
space:
mode:
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)
+