From 4716f85731625ff1d2b08d9802879cb546ff10b9 Mon Sep 17 00:00:00 2001 From: Colin Rofls Date: Mon, 12 Dec 2022 19:09:21 -0500 Subject: [PATCH] [feaLib] Sort name table entries in builder This patch ensures that feaLib always produces a name table with entries sorted in the order proscribed by the spec: platform id, encoding id, language id, name id. This breaks some tests, and so I have manually updated the test data to match the new outputs. --- Lib/fontTools/feaLib/builder.py | 1 + README.rst | 4 ++-- Tests/feaLib/data/name.ttx | 18 +++++++++--------- Tests/feaLib/data/spec8b.ttx | 8 ++++---- Tests/feaLib/data/spec8c.ttx | 14 +++++++------- Tests/feaLib/data/spec8d.ttx | 28 ++++++++++++++-------------- Tests/feaLib/data/spec9e.ttx | 4 ++-- 7 files changed, 39 insertions(+), 38 deletions(-) diff --git a/Lib/fontTools/feaLib/builder.py b/Lib/fontTools/feaLib/builder.py index 3e36e5ebe..e298eb67b 100644 --- a/Lib/fontTools/feaLib/builder.py +++ b/Lib/fontTools/feaLib/builder.py @@ -446,6 +446,7 @@ class Builder(object): assert self.cv_parameters_ids_[tag] is not None nameID = self.cv_parameters_ids_[tag] table.setName(string, nameID, platformID, platEncID, langID) + table.names.sort() def build_OS_2(self): if not self.os2_: diff --git a/README.rst b/README.rst index 8624129de..182674731 100644 --- a/README.rst +++ b/README.rst @@ -260,8 +260,8 @@ Famira, Sam Fishman, Matt Fontaine, Takaaki Fuji, Yannis Haralambous, Greg Hitchcock, Jeremie Hornus, Khaled Hosny, John Hudson, Denis Moyogo Jacquerye, Jack Jansen, Tom Kacvinsky, Jens Kutilek, Antoine Leca, Werner Lemberg, Tal Leming, Peter Lofting, Cosimo Lupo, Olli Meier, Masaya Nakamura, Dave Opstad, -Laurence Penney, Roozbeh Pournader, Garret Rieger, Read Roberts, Guido -van Rossum, Just van Rossum, Andreas Seidel, Georg Seifert, Chris +Laurence Penney, Roozbeh Pournader, Garret Rieger, Read Roberts, Colin Rofls, +Guido van Rossum, Just van Rossum, Andreas Seidel, Georg Seifert, Chris Simpkins, Miguel Sousa, Adam Twardoch, Adrien Tétar, Vitaly Volkov, Paul Wise. diff --git a/Tests/feaLib/data/name.ttx b/Tests/feaLib/data/name.ttx index 5014b2519..51ecf3241 100644 --- a/Tests/feaLib/data/name.ttx +++ b/Tests/feaLib/data/name.ttx @@ -2,6 +2,15 @@ + + Test8 + + + Test10 + + + Test11 + Test1 @@ -23,18 +32,9 @@ Test7 - - Test8 - Test9 - - Test10 - - - Test11 - diff --git a/Tests/feaLib/data/spec8b.ttx b/Tests/feaLib/data/spec8b.ttx index 6e66c16b1..5c8cba276 100644 --- a/Tests/feaLib/data/spec8b.ttx +++ b/Tests/feaLib/data/spec8b.ttx @@ -2,15 +2,15 @@ - - Win MinionPro Size Name - Mac MinionPro Size Name Mac MinionPro Size Name + + Win MinionPro Size Name + @@ -37,7 +37,7 @@ - + diff --git a/Tests/feaLib/data/spec8c.ttx b/Tests/feaLib/data/spec8c.ttx index a5b55176b..f17898db1 100644 --- a/Tests/feaLib/data/spec8c.ttx +++ b/Tests/feaLib/data/spec8c.ttx @@ -2,18 +2,18 @@ - - Feature description for MS Platform, script Unicode, language English - - - Feature description for MS Platform, script Unicode, language Japanese - Feature description for Apple Platform, script Roman, language unspecified Feature description for Apple Platform, script Japanese, language Japanese + + Feature description for MS Platform, script Unicode, language English + + + Feature description for MS Platform, script Unicode, language Japanese + @@ -39,7 +39,7 @@ - + diff --git a/Tests/feaLib/data/spec8d.ttx b/Tests/feaLib/data/spec8d.ttx index 9848a691a..5ff20ef7b 100644 --- a/Tests/feaLib/data/spec8d.ttx +++ b/Tests/feaLib/data/spec8d.ttx @@ -2,36 +2,36 @@ - + uilabel simple a - + + tool tip simple a + + + sample text simple a + + + param1 text simple a + + + param2 text simple a + + uilabel simple a tool tip simple a - - tool tip simple a - sample text simple a - - sample text simple a - param1 text simple a - - param1 text simple a - param2 text simple a - - param2 text simple a - diff --git a/Tests/feaLib/data/spec9e.ttx b/Tests/feaLib/data/spec9e.ttx index 5119a5fcd..4c63b47a5 100644 --- a/Tests/feaLib/data/spec9e.ttx +++ b/Tests/feaLib/data/spec9e.ttx @@ -2,10 +2,10 @@ - + Joachim Müller-Lancé - + Joachim Müller-Lancé