From 8b69b9412e6ccf3aad4fa488470a0c2a18d0176f Mon Sep 17 00:00:00 2001 From: David Corbett Date: Sat, 13 May 2023 13:24:58 -0400 Subject: [PATCH] feaLib: Dedupe multiple substitutions with classes --- Lib/fontTools/feaLib/ast.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/Lib/fontTools/feaLib/ast.py b/Lib/fontTools/feaLib/ast.py index bbe6e6e74..17c6cc3fb 100644 --- a/Lib/fontTools/feaLib/ast.py +++ b/Lib/fontTools/feaLib/ast.py @@ -1272,15 +1272,18 @@ class MultipleSubstStatement(Statement): replaces.append(replace) replaces = list(zip(*replaces)) + seen_originals = set() for i, original in enumerate(originals): - builder.add_multiple_subst( - self.location, - prefix, - original, - suffix, - replaces and replaces[i] or (), - self.forceChain, - ) + if original not in seen_originals: + seen_originals.add(original) + builder.add_multiple_subst( + self.location, + prefix, + original, + suffix, + replaces and replaces[i] or (), + self.forceChain, + ) def asFea(self, indent=""): res = "sub "