diff options
-rw-r--r-- | README.md | 1 | ||||
-rwxr-xr-x | scripts/lib/fontbuild/features.py | 19 |
2 files changed, 15 insertions, 5 deletions
@@ -2,6 +2,7 @@ The Roboto build toolchain depends on: - FontTools (https://github.com/behdad/fonttools) - RoboFab (https://github.com/robofab-developers/robofab) +- An expanded version of Tal Leming's feaTools (https://github.com/jamesgk/feaTools/tree/expanded) Overlap removal depends on the "booleanOperations" (https://github.com/typemytype/booleanOperations) library, which is included in `scripts/lib/`. You may need to replace its `pyclipper.so` with `pyclipper-MAC.so` or `pyclipper-LINUX.so`, depending on your platform, or compile the cpp wrapper yourself according to the instructions found on GitHub. ### OTF Generation diff --git a/scripts/lib/fontbuild/features.py b/scripts/lib/fontbuild/features.py index 898aa56..1f59801 100755 --- a/scripts/lib/fontbuild/features.py +++ b/scripts/lib/fontbuild/features.py @@ -26,7 +26,7 @@ parser.classContentRE = re.compile( parser.sequenceInlineClassRE = re.compile(
"\[" # [
"([\w\d\s_.@']+)" # content
- "\]" # ]
+ "\]'?" # ], optional contextual marking
)
# allow apostrophes in the target and replacement of a substitution
@@ -76,8 +76,19 @@ class FilterFeatureWriter(FDKSyntaxFeatureWriter): """Use this class for nested expressions e.g. in feature definitions."""
return FilterFeatureWriter(self.refs, name, isFeature)
+ def _flattenRefs(self, refs):
+ """Flatten a list of references."""
+ flatRefs = []
+ for ref in refs:
+ if type(ref) == list:
+ flatRefs.extend(self._flattenRefs(ref))
+ elif ref != "'": # ignore contextual class markings
+ flatRefs.append(ref)
+ return flatRefs
+
def _checkRefs(self, refs, errorMsg):
"""Check a list of references found in a sub or pos rule."""
+ refs = self._flattenRefs(refs)
for ref in refs:
# trailing apostrophes should be ignored
if ref[-1] == "'":
@@ -105,14 +116,12 @@ class FilterFeatureWriter(FDKSyntaxFeatureWriter): def gsubType1(self, target, replacement):
"""Check a sub rule with one-to-one replacement."""
- if type(target) == str:
- target, replacement = [target], [replacement]
- if self._checkRefs(target + replacement, self.subErr):
+ if self._checkRefs([target, replacement], self.subErr):
super(FilterFeatureWriter, self).gsubType1(target, replacement)
def gsubType4(self, target, replacement):
"""Check a sub rule with many-to-one replacement."""
- if self._checkRefs(target + [replacement], self.subErr):
+ if self._checkRefs([target, replacement], self.subErr):
super(FilterFeatureWriter, self).gsubType4(target, replacement)
def gposType1(self, target, value):
|