Skip to content

Commit

Permalink
Also return True if the default source is the only one containing fea…
Browse files Browse the repository at this point in the history
…tures.

This allows us to use variable features more easily by putting them in the
default UFO only.
  • Loading branch information
justvanrossum committed Apr 28, 2024
1 parent 8e9e6eb commit 1c69bd8
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 designSpaceDoc.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 1c69bd8

Please sign in to comment.