diff options
author | Rasmus Andersson <rasmus@notion.se> | 2018-09-03 22:55:49 +0300 |
---|---|---|
committer | Rasmus Andersson <rasmus@notion.se> | 2018-09-03 22:55:49 +0300 |
commit | c833e252c925e8dd68108660710ca835d95daa6f (patch) | |
tree | 6b2e28264ed45efd7f054e453b622098d0d875b8 /misc/pylib/robofab/tools/fontlabFeatureSplitter.py | |
parent | 8c1a4c181ef12000179dfec541f1af87e9b03122 (diff) | |
download | inter-c833e252c925e8dd68108660710ca835d95daa6f.tar.xz |
Major overhaul, moving from UFO2 to Glyphs and UFO3, plus a brand new and much simpler fontbuild
Diffstat (limited to 'misc/pylib/robofab/tools/fontlabFeatureSplitter.py')
-rw-r--r-- | misc/pylib/robofab/tools/fontlabFeatureSplitter.py | 85 |
1 files changed, 0 insertions, 85 deletions
diff --git a/misc/pylib/robofab/tools/fontlabFeatureSplitter.py b/misc/pylib/robofab/tools/fontlabFeatureSplitter.py deleted file mode 100644 index 3e0173dfc..000000000 --- a/misc/pylib/robofab/tools/fontlabFeatureSplitter.py +++ /dev/null @@ -1,85 +0,0 @@ -import re - -featureRE = re.compile( - "^" # start of line - "\s*" # - "feature" # feature - "\s+" # - "(\w{4})" # four alphanumeric characters - "\s*" # - "\{" # { - , re.MULTILINE # run in multiline to preserve line seps -) - -def splitFeaturesForFontLab(text): - """ - >>> result = splitFeaturesForFontLab(testText) - >>> result == expectedTestResult - True - """ - classes = "" - features = [] - while text: - m = featureRE.search(text) - if m is None: - classes = text - text = "" - else: - start, end = m.span() - # if start is not zero, this is the first match - # and all previous lines are part of the "classes" - if start > 0: - assert not classes - classes = text[:start] - # extract the current feature - featureName = m.group(1) - featureText = text[start:end] - text = text[end:] - # grab all text before the next feature definition - # and add it to the current definition - if text: - m = featureRE.search(text) - if m is not None: - start, end = m.span() - featureText += text[:start] - text = text[start:] - else: - featureText += text - text = "" - # store the feature - features.append((featureName, featureText)) - return classes, features - -testText = """ -@class1 = [a b c d]; - -feature liga { - sub f i by fi; -} liga; - -@class2 = [x y z]; - -feature salt { - sub a by a.alt; -} salt; feature ss01 {sub x by x.alt} ss01; - -feature ss02 {sub y by y.alt} ss02; - -# feature calt { -# sub a b' by b.alt; -# } calt; -""" - -expectedTestResult = ( - "\n@class1 = [a b c d];\n", - [ - ("liga", "\nfeature liga {\n sub f i by fi;\n} liga;\n\n@class2 = [x y z];\n"), - ("salt", "\nfeature salt {\n sub a by a.alt;\n} salt; feature ss01 {sub x by x.alt} ss01;\n"), - ("ss02", "\nfeature ss02 {sub y by y.alt} ss02;\n\n# feature calt {\n# sub a b' by b.alt;\n# } calt;\n") - ] -) - - -if __name__ == "__main__": - import doctest - doctest.testmod() |