Do not fail on duplicate multiple substitutions
This commit is contained in:
parent
a37dab3824
commit
62ed43ddb9
@ -892,9 +892,17 @@ class Builder(object):
|
|||||||
return
|
return
|
||||||
lookup = self.get_lookup_(location, MultipleSubstBuilder)
|
lookup = self.get_lookup_(location, MultipleSubstBuilder)
|
||||||
if glyph in lookup.mapping:
|
if glyph in lookup.mapping:
|
||||||
raise FeatureLibError(
|
if replacements == lookup.mapping[glyph]:
|
||||||
'Already defined substitution for glyph "%s"' % glyph,
|
log.info(
|
||||||
location)
|
'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
|
lookup.mapping[glyph] = replacements
|
||||||
|
|
||||||
def add_reverse_chain_single_subst(self, location, old_prefix,
|
def add_reverse_chain_single_subst(self, location, old_prefix,
|
||||||
|
@ -206,9 +206,20 @@ class BuilderTest(unittest.TestCase):
|
|||||||
"feature test {"
|
"feature test {"
|
||||||
" sub f_f_i by f f i;"
|
" sub f_f_i by f f i;"
|
||||||
" sub c_t by c t;"
|
" sub c_t by c t;"
|
||||||
" sub f_f_i by f f i;"
|
" sub f_f_i by f_f i;"
|
||||||
"} test;")
|
"} 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):
|
def test_pairPos_redefinition_warning(self):
|
||||||
# https://github.com/fonttools/fonttools/issues/1147
|
# https://github.com/fonttools/fonttools/issues/1147
|
||||||
logger = logging.getLogger("fontTools.feaLib.builder")
|
logger = logging.getLogger("fontTools.feaLib.builder")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user