Skip to content

Commit

Permalink
Merge pull request #833 from justvanrossum/broaden-var-features-check
Browse files Browse the repository at this point in the history
Make it easier to use variable features by allowing to put them in the default source only
  • Loading branch information
anthrotype authored May 13, 2024
2 parents 8e9e6eb + 1627f60 commit c85b363
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions Lib/ufo2ft/featureCompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,8 @@ def setupFeatures(self):


def _featuresCompatible(designSpaceDoc: DesignSpaceDocument) -> bool:
"""Returns whether the features of the individual source UFOs are the same.
"""Returns True when the features of the individual source UFOs are the same,
or when only the default source has features.
NOTE: Only compares the feature file text inside the source UFO and does not
follow imports. This will suffice as long as no external feature file is
Expand All @@ -463,5 +464,13 @@ def transform(f: SourceDescriptor) -> str:
text = re.sub(r"\s+", " ", text)
return text

first = transform(designSpaceDoc.sources[0])
return all(transform(s) == first for s in designSpaceDoc.sources[1:])
sources = sorted(
designSpaceDoc.sources, key=lambda source: source != designSpaceDoc.default
)
assert sources[0] == designSpaceDoc.default

transformed = [transform(s) for s in sources]
first = transformed[0]
return all(s == first for s in transformed[1:]) or all(
not s for s in transformed[1:]
)

0 comments on commit c85b363

Please sign in to comment.