Fix: Monospaced fonts wrong width

[why]
With commit
  821ac6817  Create symbols only font directly from sfd template

we have a default width for source fonts without a width (i.e. empty
fonts).

Unfortunately the detection for 'empty font' is wrong.

[how]
Reorder the commands such that we have a meaningful calculation.

Maybe this has been broken by too many (manual) rebases.

Fixes: #895

Reported-by: redactedscribe
Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
This commit is contained in:
Fini Jastrow 2022-08-26 19:07:17 +02:00
parent a334db4180
commit b71a9e474b

View file

@ -835,7 +835,7 @@ class font_patcher:
# Ignore the y-values, os2_winXXXXX values set above are used for line height
#
# 0x00-0x17f is the Latin Extended-A range
for glyph in range(0x00, 0x17f):
for glyph in range(0x21, 0x17f):
if glyph in range(0x7F, 0xBF):
continue # ignore special characters like '1/4' etc
try:
@ -848,6 +848,7 @@ class font_patcher:
self.font_dim['xmax'] = xmax
# Calculate font height
self.font_dim['height'] = abs(self.font_dim['ymin']) + self.font_dim['ymax']
if self.font_dim['height'] == 0:
# This can only happen if the input font is empty
# Assume we are using our prepared templates
@ -857,9 +858,8 @@ class font_patcher:
'xmax' : self.sourceFont.em,
'ymax' : self.sourceFont.ascent,
'width' : self.sourceFont.em,
'height': 0,
'height': abs(self.sourceFont.descent) + self.sourceFont.ascent,
}
self.font_dim['height'] = abs(self.font_dim['ymin']) + self.font_dim['ymax']
def get_scale_factor(self, sym_dim):