diff options
author | robot-piglet <[email protected]> | 2025-06-18 23:55:52 +0300 |
---|---|---|
committer | robot-piglet <[email protected]> | 2025-06-19 00:06:55 +0300 |
commit | 61ea5fc0cd73730d5ae6a9186d8c15057f183095 (patch) | |
tree | 31ddc3fcbabb680d9ce733ea36f581a6d062aff9 /contrib/python/fonttools/fontTools/feaLib/ast.py | |
parent | 2fcfb855cd7780ab07751cc16c80a0a58168668a (diff) |
Intermediate changes
commit_hash:283b0c2ecb46f54501d7d1b92643c0090cebaa95
Diffstat (limited to 'contrib/python/fonttools/fontTools/feaLib/ast.py')
-rw-r--r-- | contrib/python/fonttools/fontTools/feaLib/ast.py | 73 |
1 files changed, 1 insertions, 72 deletions
diff --git a/contrib/python/fonttools/fontTools/feaLib/ast.py b/contrib/python/fonttools/fontTools/feaLib/ast.py index 8479d7300d6..efcce8c680b 100644 --- a/contrib/python/fonttools/fontTools/feaLib/ast.py +++ b/contrib/python/fonttools/fontTools/feaLib/ast.py @@ -337,76 +337,6 @@ class AnonymousBlock(Statement): return res -def _upgrade_mixed_subst_statements(statements): - # https://github.com/fonttools/fonttools/issues/612 - # A multiple substitution may have a single destination, in which case - # it will look just like a single substitution. So if there are both - # multiple and single substitutions, upgrade all the single ones to - # multiple substitutions. Similarly, a ligature substitution may have a - # single source glyph, so if there are both ligature and single - # substitutions, upgrade all the single ones to ligature substitutions. - - has_single = False - has_multiple = False - has_ligature = False - for s in statements: - if isinstance(s, SingleSubstStatement): - has_single = not any([s.prefix, s.suffix, s.forceChain]) - elif isinstance(s, MultipleSubstStatement): - has_multiple = not any([s.prefix, s.suffix, s.forceChain]) - elif isinstance(s, LigatureSubstStatement): - has_ligature = not any([s.prefix, s.suffix, s.forceChain]) - - to_multiple = False - to_ligature = False - - # If we have mixed single and multiple substitutions, - # upgrade all single substitutions to multiple substitutions. - if has_single and has_multiple and not has_ligature: - to_multiple = True - - # If we have mixed single and ligature substitutions, - # upgrade all single substitutions to ligature substitutions. - elif has_single and has_ligature and not has_multiple: - to_ligature = True - - if to_multiple or to_ligature: - ret = [] - for s in statements: - if isinstance(s, SingleSubstStatement): - glyphs = s.glyphs[0].glyphSet() - replacements = s.replacements[0].glyphSet() - if len(replacements) == 1: - replacements *= len(glyphs) - for glyph, replacement in zip(glyphs, replacements): - if to_multiple: - ret.append( - MultipleSubstStatement( - s.prefix, - glyph, - s.suffix, - [replacement], - s.forceChain, - location=s.location, - ) - ) - elif to_ligature: - ret.append( - LigatureSubstStatement( - s.prefix, - [GlyphName(glyph)], - s.suffix, - replacement, - s.forceChain, - location=s.location, - ) - ) - else: - ret.append(s) - return ret - return statements - - class Block(Statement): """A block of statements: feature, lookup, etc.""" @@ -418,8 +348,7 @@ class Block(Statement): """When handed a 'builder' object of comparable interface to :class:`fontTools.feaLib.builder`, walks the statements in this block, calling the builder callbacks.""" - statements = _upgrade_mixed_subst_statements(self.statements) - for s in statements: + for s in self.statements: s.build(builder) def asFea(self, indent=""): |