font-patcher: Fix vertical alignment for non-Mono with ScaleGlyph

[why]
When creating a non-Mono font the vertical alignment does not observe a
possible ScaleGlyph group. Icons that should be far up (like the
degree-icon, which is ScaleGlyph-grouped together with a full height
symbol) end up centered vertically.

[how]
When the glyph is not scaled we just do not use the ScaleGlyph.
But that data is also needed for just shifting the glyph.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
This commit is contained in:
Fini Jastrow 2022-12-21 18:31:53 +01:00
parent f72104ed9b
commit 417395c1a0

View file

@ -1063,9 +1063,12 @@ class font_patcher:
# Use the dimensions from the newly pasted and stretched glyph to avoid any rounding errors
sym_dim = get_glyph_dimensions(self.sourceFont[currentSourceFontGlyph])
# Use combined bounding box?
if scale_glyph_data and scale_glyph_data[1] and (scale_ratio_x != 1 or scale_ratio_y != 1):
# Simulate scaling on combined bounding box
scaleglyph_dim = scale_bounding_box(scale_glyph_data[1], scale_ratio_x, scale_ratio_y)
if scale_glyph_data and scale_glyph_data[1]:
if scale_ratio_x != 1 or scale_ratio_y != 1:
# Simulate scaling on combined bounding box
scaleglyph_dim = scale_bounding_box(scale_glyph_data[1], scale_ratio_x, scale_ratio_y)
else:
scaleglyph_dim = scale_glyph_data[1]
if not scaleglyph_dim['advance']:
# On monospaced symbol collections use their advance with, otherwise align horizontally individually
scaleglyph_dim['xmin'] = sym_dim['xmin']