feaLib: ensure languagesystems using 'DFLT' script tag precede all others
https://github.com/fonttools/fonttools/pull/1292#issuecomment-407427544 this is to match makeotf's behavior https://github.com/adobe-type-tools/afdko/pull/498/files#diff-17824930b3cdfb707ae56e1f42bccec6R2305
This commit is contained in:
parent
1740d18584
commit
d3229d5777
@ -59,6 +59,7 @@ class Builder(object):
|
||||
self.lookupflag_ = 0
|
||||
self.lookupflag_markFilterSet_ = None
|
||||
self.language_systems = set()
|
||||
self.seen_non_DFLT_script_ = False
|
||||
self.named_lookups_ = {}
|
||||
self.cur_lookup_ = None
|
||||
self.cur_lookup_name_ = None
|
||||
@ -616,6 +617,15 @@ class Builder(object):
|
||||
raise FeatureLibError(
|
||||
'If "languagesystem DFLT dflt" is present, it must be '
|
||||
'the first of the languagesystem statements', location)
|
||||
if script == "DFLT":
|
||||
if self.seen_non_DFLT_script_:
|
||||
raise FeatureLibError(
|
||||
'languagesystems using the "DFLT" script tag must '
|
||||
"precede all other languagesystems",
|
||||
location
|
||||
)
|
||||
else:
|
||||
self.seen_non_DFLT_script_ = True
|
||||
if (script, language) in self.default_language_systems_:
|
||||
raise FeatureLibError(
|
||||
'"languagesystem %s %s" has already been specified' %
|
||||
|
@ -285,6 +285,17 @@ class BuilderTest(unittest.TestCase):
|
||||
"it must be the first of the languagesystem statements",
|
||||
self.build, "languagesystem latn TRK; languagesystem DFLT dflt;")
|
||||
|
||||
def test_languagesystem_DFLT_not_preceding(self):
|
||||
self.assertRaisesRegex(
|
||||
FeatureLibError,
|
||||
"languagesystems using the \"DFLT\" script tag must "
|
||||
"precede all other languagesystems",
|
||||
self.build,
|
||||
"languagesystem DFLT dflt; "
|
||||
"languagesystem latn dflt; "
|
||||
"languagesystem DFLT fooo; "
|
||||
)
|
||||
|
||||
def test_script(self):
|
||||
builder = Builder(makeTTFont(), (None, None))
|
||||
builder.start_feature(location=None, name='test')
|
||||
|
Loading…
x
Reference in New Issue
Block a user