1
0
mirror of https://github.com/ryanoasis/nerd-fonts.git synced 2025-01-25 03:32:02 +02:00

font-patcher: Correct mono scaling of thin glyphs

[why]
Some glyphs that are tall and thin, are too big in the resulting patched
font, i.e. are higher than our 'line'.

At least for --mono fonts. The non-mono fonts do not rescale the
inserted glyphs at all, so there is no definition of 'too tall/wide'.

[how]
We want all glyphs to fit into the box defined by *_dim['height'] and
*_dim['widths'], as it also defines our powerline-glyph scaling and
horizontal and vertical advance widths.

So we need to take that value (instead of EM) for the scaling
calculation. The history of the use of EM here is a bit obscure, more
explanations in the PR.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
This commit is contained in:
Fini Jastrow 2022-01-01 11:46:37 +01:00 committed by Fini
parent 4a61afc83a
commit b2fa537e7f

View File

@ -901,10 +901,7 @@ class font_patcher:
# We want to preserve x/y aspect ratio, so find biggest scale factor that allows symbol to fit
scale_ratio_x = self.font_dim['width'] / sym_dim['width']
# font_dim['height'] represents total line height, keep our symbols sized based upon font's em
# NOTE: is this comment correct? font_dim['height'] isn't used here
scale_ratio_y = self.sourceFont.em / sym_dim['height']
scale_ratio_y = self.font_dim['height'] / sym_dim['height']
if scale_ratio_x > scale_ratio_y:
scale_ratio = scale_ratio_y
else: