Log warning instead of raising an error when identical substitutions are added again

This commit is contained in:
Jens Kutilek 2019-12-02 17:05:59 +01:00
parent 9d3b14dd5f
commit 9c6b7d2e7a

View File

@ -914,6 +914,15 @@ class Builder(object):
lookup = self.get_lookup_(location, SingleSubstBuilder) lookup = self.get_lookup_(location, SingleSubstBuilder)
for (from_glyph, to_glyph) in mapping.items(): for (from_glyph, to_glyph) in mapping.items():
if from_glyph in lookup.mapping: if from_glyph in lookup.mapping:
if to_glyph == lookup.mapping[from_glyph]:
# log warning?
# FDK logs "[NOTE] Removing duplicate single substitution in 'xxxx' feature: from_glyph, to_glyph" in this case
log.info(FeatureLibError(
'Removing duplicate single substitution for glyph "%s" by "%s"' %
(from_glyph, to_glyph),
location
))
else:
raise FeatureLibError( raise FeatureLibError(
'Already defined rule for replacing glyph "%s" by "%s"' % 'Already defined rule for replacing glyph "%s" by "%s"' %
(from_glyph, lookup.mapping[from_glyph]), (from_glyph, lookup.mapping[from_glyph]),