name_parser: Correct output on weight check

[why]
When the weight check fails for some input the reason is not shown
correctly (i.e. not the string that actually failed).

[how]
Display exactly the failed string in the warning.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
This commit is contained in:
Fini Jastrow 2023-10-07 12:42:45 +02:00 committed by Fini
parent 809101da32
commit 89f1325205

View file

@ -285,10 +285,10 @@ class FontnameParser:
name_weight = FontnameTools.weight_string_to_number(weight)
weightproblem = False
if ps_weight is None:
self.logger.warn('Can not parse PS-weight: {}'.format(restored_weight_token))
self.logger.warn('Can not parse PS-weight: {}'.format(font.weight))
weightproblem = True
if name_weight is None:
self.logger.warn('Can not parse name for weight: {}'.format(restored_weight_token))
self.logger.warn('Can not parse name for weight: {}'.format(weight))
weightproblem = True
if weightproblem or abs(os2_weight - ps_weight) > 50 or abs(os2_weight - name_weight) > 50:
self.logger.warning('Possible problem with the weight metadata detected, check with --debug')