Merge pull request #1811 from dscorbett/add_multiple_subst-duplicate
[feaLib] Do not fail on duplicate multiple substitutions
This commit is contained in:
commit
f609293dc7
@ -892,9 +892,17 @@ class Builder(object):
|
||||
return
|
||||
lookup = self.get_lookup_(location, MultipleSubstBuilder)
|
||||
if glyph in lookup.mapping:
|
||||
raise FeatureLibError(
|
||||
'Already defined substitution for glyph "%s"' % glyph,
|
||||
location)
|
||||
if replacements == lookup.mapping[glyph]:
|
||||
log.info(
|
||||
'Removing duplicate multiple substitution from glyph'
|
||||
' "%s" to %s%s',
|
||||
glyph, replacements,
|
||||
' at {}:{}:{}'.format(*location) if location else '',
|
||||
)
|
||||
else:
|
||||
raise FeatureLibError(
|
||||
'Already defined substitution for glyph "%s"' % glyph,
|
||||
location)
|
||||
lookup.mapping[glyph] = replacements
|
||||
|
||||
def add_reverse_chain_single_subst(self, location, old_prefix,
|
||||
|
@ -206,9 +206,20 @@ class BuilderTest(unittest.TestCase):
|
||||
"feature test {"
|
||||
" sub f_f_i by f f i;"
|
||||
" sub c_t by c t;"
|
||||
" sub f_f_i by f f i;"
|
||||
" sub f_f_i by f_f i;"
|
||||
"} test;")
|
||||
|
||||
def test_multipleSubst_multipleIdenticalSubstitutionsForSameGlyph_info(self):
|
||||
logger = logging.getLogger("fontTools.feaLib.builder")
|
||||
with CapturingLogHandler(logger, "INFO") as captor:
|
||||
self.build(
|
||||
"feature test {"
|
||||
" sub f_f_i by f f i;"
|
||||
" sub c_t by c t;"
|
||||
" sub f_f_i by f f i;"
|
||||
"} test;")
|
||||
captor.assertRegex(r"Removing duplicate multiple substitution from glyph \"f_f_i\" to \('f', 'f', 'i'\)")
|
||||
|
||||
def test_pairPos_redefinition_warning(self):
|
||||
# https://github.com/fonttools/fonttools/issues/1147
|
||||
logger = logging.getLogger("fontTools.feaLib.builder")
|
||||
|
Loading…
x
Reference in New Issue
Block a user