diff options
author | robot-piglet <robot-piglet@yandex-team.com> | 2024-07-20 07:38:40 +0300 |
---|---|---|
committer | robot-piglet <robot-piglet@yandex-team.com> | 2024-07-20 07:58:13 +0300 |
commit | 7d21c95992e12e49a9afe45263936a45fb902b6e (patch) | |
tree | 567f7119eaccd4c2dfd9be500066a7b904cc0279 /contrib/python/fonttools/fontTools | |
parent | 1eafc358f721395d1eac1a4480f51ee78c966485 (diff) | |
download | ydb-7d21c95992e12e49a9afe45263936a45fb902b6e.tar.gz |
Intermediate changes
Diffstat (limited to 'contrib/python/fonttools/fontTools')
5 files changed, 28 insertions, 13 deletions
diff --git a/contrib/python/fonttools/fontTools/__init__.py b/contrib/python/fonttools/fontTools/__init__.py index 0de5c155e3..f2c62f124b 100644 --- a/contrib/python/fonttools/fontTools/__init__.py +++ b/contrib/python/fonttools/fontTools/__init__.py @@ -3,6 +3,6 @@ from fontTools.misc.loggingTools import configLogger log = logging.getLogger(__name__) -version = __version__ = "4.53.0" +version = __version__ = "4.53.1" __all__ = ["version", "log", "configLogger"] diff --git a/contrib/python/fonttools/fontTools/feaLib/builder.py b/contrib/python/fonttools/fontTools/feaLib/builder.py index a91381ddc1..bda855e1e9 100644 --- a/contrib/python/fonttools/fontTools/feaLib/builder.py +++ b/contrib/python/fonttools/fontTools/feaLib/builder.py @@ -1286,10 +1286,7 @@ class Builder(object): self, location, prefix, glyph, suffix, replacements, forceChain=False ): if prefix or suffix or forceChain: - chain = self.get_lookup_(location, ChainContextSubstBuilder) - sub = self.get_chained_lookup_(location, MultipleSubstBuilder) - sub.mapping[glyph] = replacements - chain.rules.append(ChainContextualRule(prefix, [{glyph}], suffix, [sub])) + self.add_multi_subst_chained_(location, prefix, glyph, suffix, replacements) return lookup = self.get_lookup_(location, MultipleSubstBuilder) if glyph in lookup.mapping: @@ -1369,7 +1366,7 @@ class Builder(object): # https://github.com/fonttools/fonttools/issues/512 # https://github.com/fonttools/fonttools/issues/2150 chain = self.get_lookup_(location, ChainContextSubstBuilder) - sub = chain.find_chainable_single_subst(mapping) + sub = chain.find_chainable_subst(mapping, SingleSubstBuilder) if sub is None: sub = self.get_chained_lookup_(location, SingleSubstBuilder) sub.mapping.update(mapping) @@ -1377,6 +1374,19 @@ class Builder(object): ChainContextualRule(prefix, [list(mapping.keys())], suffix, [sub]) ) + def add_multi_subst_chained_(self, location, prefix, glyph, suffix, replacements): + if not all(prefix) or not all(suffix): + raise FeatureLibError( + "Empty glyph class in contextual substitution", location + ) + # https://github.com/fonttools/fonttools/issues/3551 + chain = self.get_lookup_(location, ChainContextSubstBuilder) + sub = chain.find_chainable_subst({glyph: replacements}, MultipleSubstBuilder) + if sub is None: + sub = self.get_chained_lookup_(location, MultipleSubstBuilder) + sub.mapping[glyph] = replacements + chain.rules.append(ChainContextualRule(prefix, [{glyph}], suffix, [sub])) + # GSUB 8 def add_reverse_chain_single_subst(self, location, old_prefix, old_suffix, mapping): if not mapping: diff --git a/contrib/python/fonttools/fontTools/misc/visitor.py b/contrib/python/fonttools/fontTools/misc/visitor.py index d289895467..6de432ef93 100644 --- a/contrib/python/fonttools/fontTools/misc/visitor.py +++ b/contrib/python/fonttools/fontTools/misc/visitor.py @@ -61,9 +61,10 @@ class Visitor(object): if _visitors is None: break - m = celf._visitors.get(typ, None) - if m is not None: - return m + for base in typ.mro(): + m = celf._visitors.get(base, None) + if m is not None: + return m return _default diff --git a/contrib/python/fonttools/fontTools/otlLib/builder.py b/contrib/python/fonttools/fontTools/otlLib/builder.py index 70fd87ab57..8fc685683a 100644 --- a/contrib/python/fonttools/fontTools/otlLib/builder.py +++ b/contrib/python/fonttools/fontTools/otlLib/builder.py @@ -544,6 +544,10 @@ class ChainContextualBuilder(LookupBuilder): f"{classRuleAttr}Count", getattr(setForThisRule, f"{classRuleAttr}Count") + 1, ) + for i, classSet in enumerate(classSets): + if not getattr(classSet, classRuleAttr): + # class sets can be null so replace nop sets with None + classSets[i] = None setattr(st, self.ruleSetAttr_(format=2, chaining=chaining), classSets) setattr( st, self.ruleSetAttr_(format=2, chaining=chaining) + "Count", len(classSets) @@ -781,14 +785,14 @@ class ChainContextSubstBuilder(ChainContextualBuilder): ) return result - def find_chainable_single_subst(self, mapping): - """Helper for add_single_subst_chained_()""" + def find_chainable_subst(self, mapping, builder_class): + """Helper for add_{single,multi}_subst_chained_()""" res = None for rule in self.rules[::-1]: if rule.is_subtable_break: return res for sub in rule.lookups: - if isinstance(sub, SingleSubstBuilder) and not any( + if isinstance(sub, builder_class) and not any( g in mapping and mapping[g] != sub.mapping[g] for g in sub.mapping ): res = sub diff --git a/contrib/python/fonttools/fontTools/otlLib/maxContextCalc.py b/contrib/python/fonttools/fontTools/otlLib/maxContextCalc.py index 03e7561b60..eee8d48f3c 100644 --- a/contrib/python/fonttools/fontTools/otlLib/maxContextCalc.py +++ b/contrib/python/fonttools/fontTools/otlLib/maxContextCalc.py @@ -92,5 +92,5 @@ def maxCtxContextualRule(maxCtx, st, chain): if not chain: return max(maxCtx, st.GlyphCount) elif chain == "Reverse": - return max(maxCtx, st.GlyphCount + st.LookAheadGlyphCount) + return max(maxCtx, 1 + st.LookAheadGlyphCount) return max(maxCtx, st.InputGlyphCount + st.LookAheadGlyphCount) |