From 9dd2f928491954786c893b776e14aa3e5fb00e46 Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Wed, 28 Aug 2024 22:35:54 +0300 Subject: [PATCH] Fix the order of feature writers We want curs feature lookups to come first, then kerning, then mark/mkmk, but we currently are calling CursFeatureWriter last which causes its lookups to be also written last. The lookup order does not matter for HarfBuzz, but it matters for other implementations, see: https://github.com/harfbuzz/harfbuzz/issues/4596#issuecomment-2220558649 --- Lib/ufo2ft/featureCompiler.py | 2 +- .../variableFeatureWriter_test.py | 20 +++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Lib/ufo2ft/featureCompiler.py b/Lib/ufo2ft/featureCompiler.py index 8af6318b..f18621a1 100644 --- a/Lib/ufo2ft/featureCompiler.py +++ b/Lib/ufo2ft/featureCompiler.py @@ -172,10 +172,10 @@ class FeatureCompiler(BaseFeatureCompiler): """ defaultFeatureWriters = [ + CursFeatureWriter, KernFeatureWriter, MarkFeatureWriter, GdefFeatureWriter, - CursFeatureWriter, ] def __init__( diff --git a/tests/featureWriters/variableFeatureWriter_test.py b/tests/featureWriters/variableFeatureWriter_test.py index b501c033..9217a7b7 100644 --- a/tests/featureWriters/variableFeatureWriter_test.py +++ b/tests/featureWriters/variableFeatureWriter_test.py @@ -19,6 +19,16 @@ def test_variable_features(FontClass): markClass dotabove-ar @MC_top; markClass gravecmb @MC_top; + feature curs { + lookup curs_rtl { + lookupflag RightToLeft IgnoreMarks; + pos cursive alef-ar.fina ; + pos cursive peh-ar.init ; + pos cursive peh-ar.init.BRACKET.varAlt01 ; + } curs_rtl; + + } curs; + lookup kern_Arab { lookupflag IgnoreMarks; pos alef-ar.fina alef-ar.fina <(wght=100:15 wght=1000:35) 0 (wght=100:15 wght=1000:35) 0>; @@ -47,16 +57,6 @@ def test_variable_features(FontClass): table GDEF { LigatureCaretByPos peh-ar.init 100; } GDEF; - - feature curs { - lookup curs_rtl { - lookupflag RightToLeft IgnoreMarks; - pos cursive alef-ar.fina ; - pos cursive peh-ar.init ; - pos cursive peh-ar.init.BRACKET.varAlt01 ; - } curs_rtl; - - } curs; """ # noqa: B950 )