aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/fonttools/fontTools/feaLib/builder.py
diff options
context:
space:
mode:
authorrobot-piglet <robot-piglet@yandex-team.com>2024-12-25 09:32:21 +0300
committerrobot-piglet <robot-piglet@yandex-team.com>2024-12-25 09:46:53 +0300
commit2f83984f3c96794039f6d577c2dc3eea220dbca0 (patch)
tree958ca6af85dd936face825e7fba750a5144d4eaf /contrib/python/fonttools/fontTools/feaLib/builder.py
parentf8fcb8a9bf119d91c13270ce72f2bbe35bafe0d3 (diff)
downloadydb-2f83984f3c96794039f6d577c2dc3eea220dbca0.tar.gz
Intermediate changes
commit_hash:c52dc7996a60242b5397523a3f8dada166c4c7c5
Diffstat (limited to 'contrib/python/fonttools/fontTools/feaLib/builder.py')
-rw-r--r--contrib/python/fonttools/fontTools/feaLib/builder.py25
1 files changed, 22 insertions, 3 deletions
diff --git a/contrib/python/fonttools/fontTools/feaLib/builder.py b/contrib/python/fonttools/fontTools/feaLib/builder.py
index 81aa8c2e26..1cfe1c3a13 100644
--- a/contrib/python/fonttools/fontTools/feaLib/builder.py
+++ b/contrib/python/fonttools/fontTools/feaLib/builder.py
@@ -1328,9 +1328,10 @@ class Builder(object):
self, location, prefix, glyphs, suffix, replacement, forceChain
):
if prefix or suffix or forceChain:
- chain = self.get_lookup_(location, ChainContextSubstBuilder)
- lookup = self.get_chained_lookup_(location, LigatureSubstBuilder)
- chain.rules.append(ChainContextualRule(prefix, glyphs, suffix, [lookup]))
+ self.add_ligature_subst_chained_(
+ location, prefix, glyphs, suffix, replacement
+ )
+ return
else:
lookup = self.get_lookup_(location, LigatureSubstBuilder)
@@ -1387,6 +1388,24 @@ class Builder(object):
sub.mapping[glyph] = replacements
chain.rules.append(ChainContextualRule(prefix, [{glyph}], suffix, [sub]))
+ def add_ligature_subst_chained_(
+ self, location, prefix, glyphs, suffix, replacement
+ ):
+ # https://github.com/fonttools/fonttools/issues/3701
+ if not all(prefix) or not all(suffix):
+ raise FeatureLibError(
+ "Empty glyph class in contextual substitution", location
+ )
+ chain = self.get_lookup_(location, ChainContextSubstBuilder)
+ sub = chain.find_chainable_ligature_subst(glyphs, replacement)
+ if sub is None:
+ sub = self.get_chained_lookup_(location, LigatureSubstBuilder)
+
+ for g in itertools.product(*glyphs):
+ sub.ligatures[g] = replacement
+
+ chain.rules.append(ChainContextualRule(prefix, glyphs, suffix, [sub]))
+
# GSUB 8
def add_reverse_chain_single_subst(self, location, old_prefix, old_suffix, mapping):
if not mapping: