From 957b5fb45a795b06f9a3dfd168dc2c9cc5bae3a5 Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Wed, 24 Jan 2024 12:34:48 +0000 Subject: [PATCH] don't sort product of liga components to keep declaration order technically we are tweaking the original example from the spec but it keeps the spirit, so that the product of glyph classes produces the same representation in the font as if the sequences were manually enumerated (while keeping the declaration order) --- Lib/fontTools/feaLib/builder.py | 2 +- Tests/feaLib/data/spec5d1.fea | 12 ++++++------ Tests/feaLib/data/spec5d1.ttx | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Lib/fontTools/feaLib/builder.py b/Lib/fontTools/feaLib/builder.py index 36eed9514..02151620b 100644 --- a/Lib/fontTools/feaLib/builder.py +++ b/Lib/fontTools/feaLib/builder.py @@ -1338,7 +1338,7 @@ class Builder(object): # substitutions to be specified on target sequences that contain # glyph classes, the implementation software will enumerate # all specific glyph sequences if glyph classes are detected" - for g in sorted(itertools.product(*glyphs)): + for g in itertools.product(*glyphs): lookup.ligatures[g] = replacement # GSUB 5/6 diff --git a/Tests/feaLib/data/spec5d1.fea b/Tests/feaLib/data/spec5d1.fea index cf7d76f70..a9a23f815 100644 --- a/Tests/feaLib/data/spec5d1.fea +++ b/Tests/feaLib/data/spec5d1.fea @@ -2,7 +2,7 @@ # http://www.adobe.com/devnet/opentype/afdko/topic_feature_file_syntax.html feature F1 { - sub [one one.oldstyle] [slash fraction] [two two.oldstyle] by onehalf; + sub [one one.oldstyle] [fraction slash] [two two.oldstyle] by onehalf; } F1; # Since the OpenType specification does not allow ligature substitutions @@ -12,12 +12,12 @@ feature F1 { # example produces an identical representation in the font as if all # the sequences were manually enumerated by the font editor: feature F2 { - sub one slash two by onehalf; - sub one.oldstyle slash two by onehalf; sub one fraction two by onehalf; - sub one.oldstyle fraction two by onehalf; - sub one slash two.oldstyle by onehalf; - sub one.oldstyle slash two.oldstyle by onehalf; sub one fraction two.oldstyle by onehalf; + sub one slash two by onehalf; + sub one slash two.oldstyle by onehalf; + sub one.oldstyle fraction two by onehalf; sub one.oldstyle fraction two.oldstyle by onehalf; + sub one.oldstyle slash two by onehalf; + sub one.oldstyle slash two.oldstyle by onehalf; } F2; diff --git a/Tests/feaLib/data/spec5d1.ttx b/Tests/feaLib/data/spec5d1.ttx index 79c0e8675..77dfc93b8 100644 --- a/Tests/feaLib/data/spec5d1.ttx +++ b/Tests/feaLib/data/spec5d1.ttx @@ -62,16 +62,16 @@ - - + + - - + +