feaLib: when name table not selected, skip building featureNames blocks

ufo2ft feature writer calls feaLib builder with tables=[GSUB] first, to run closure
over glyph substitutions; if the GSUB features contains 'featureNames' blocks, then
an AssertionError will be raised; in this case, we can simply skip building the
FeatureParams tables as we haven't build the name records they point to.
This commit is contained in:
Cosimo Lupo 2018-07-26 10:51:37 +01:00
parent 4f94da9d4d
commit 68951b7c3d
No known key found for this signature in database
GPG Key ID: 59D54DB0C9976482
2 changed files with 21 additions and 4 deletions

View File

@ -290,10 +290,14 @@ class Builder(object):
else:
params.SubfamilyNameID = 0
elif tag in self.featureNames_:
assert tag in self.featureNames_ids_
params = otTables.FeatureParamsStylisticSet()
params.Version = 0
params.UINameID = self.featureNames_ids_[tag]
if not self.featureNames_ids_:
# name table wasn't selected among the tables to build; skip
pass
else:
assert tag in self.featureNames_ids_
params = otTables.FeatureParamsStylisticSet()
params.Version = 0
params.UINameID = self.featureNames_ids_[tag]
elif tag in self.cv_parameters_:
params = otTables.FeatureParamsCharacterVariants()
params.Format = 0

View File

@ -524,6 +524,19 @@ class BuilderTest(unittest.TestCase):
"} liga;"
)
def test_skip_featureNames_if_no_name_table(self):
features = (
"feature ss01 {"
" featureNames {"
' name "ignored as we request to skip name table";'
" };"
" sub A by A.alt1;"
"} ss01;"
)
font = self.build(features, tables=["GSUB"])
self.assertIn("GSUB", font)
self.assertNotIn("name", font)
def generate_feature_file_test(name):
return lambda self: self.check_feature_file(name)