mirror of
https://github.com/ryanoasis/nerd-fonts.git
synced 2024-09-19 09:51:48 +02:00
font-patcher: Centralize more scaling code
[why] Obviously we can drop more code and shuffle scaling logic into the scaling function. Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
This commit is contained in:
parent
b571415e6b
commit
5f85240519
1 changed files with 5 additions and 16 deletions
21
font-patcher
21
font-patcher
|
@ -989,10 +989,14 @@ class font_patcher:
|
||||||
if stretch == 'pa':
|
if stretch == 'pa':
|
||||||
# We want to preserve x/y aspect ratio, so find biggest scale factor that allows symbol to fit
|
# We want to preserve x/y aspect ratio, so find biggest scale factor that allows symbol to fit
|
||||||
scale_ratio_x = min(scale_ratio_x, scale_ratio_y)
|
scale_ratio_x = min(scale_ratio_x, scale_ratio_y)
|
||||||
|
if not self.args.single:
|
||||||
|
# non monospaced fonts just scale down on 'pa', not up
|
||||||
|
scale_ratio_x = min(scale_ratio_x, 1.0)
|
||||||
scale_ratio_y = scale_ratio_x
|
scale_ratio_y = scale_ratio_x
|
||||||
else:
|
else:
|
||||||
# Keep the not-stretched direction
|
# Keep the not-stretched direction
|
||||||
if not 'x' in stretch:
|
if not self.args.single or not 'x' in stretch:
|
||||||
|
# non monospaced fonts scale y, on 'y' scale request (not x)
|
||||||
scale_ratio_x = 1.0
|
scale_ratio_x = 1.0
|
||||||
if not 'y' in stretch:
|
if not 'y' in stretch:
|
||||||
scale_ratio_y = 1.0
|
scale_ratio_y = 1.0
|
||||||
|
@ -1106,21 +1110,6 @@ class font_patcher:
|
||||||
else:
|
else:
|
||||||
(scale_ratio_x, scale_ratio_y) = self.get_scale_factors(sym_dim, sym_attr['stretch'])
|
(scale_ratio_x, scale_ratio_y) = self.get_scale_factors(sym_dim, sym_attr['stretch'])
|
||||||
|
|
||||||
if not self.args.single:
|
|
||||||
# any special logic we want to apply for double-width variation
|
|
||||||
# would go here:
|
|
||||||
# non monospaced fonts scale y, on 'y' scale request
|
|
||||||
# non monospaced fonts just scale down on 'pa', not up
|
|
||||||
if sym_attr['stretch'] == 'pa':
|
|
||||||
# both scale factors are the same, thus we can limit them
|
|
||||||
# individually, which is still the same
|
|
||||||
scale_ratio_x = min(scale_ratio_x, 1.0)
|
|
||||||
scale_ratio_y = min(scale_ratio_y, 1.0)
|
|
||||||
else:
|
|
||||||
scale_ratio_x = 1.0
|
|
||||||
if not 'y' in sym_attr['stretch']:
|
|
||||||
scale_ratio_y = 1.0
|
|
||||||
|
|
||||||
overlap = sym_attr['params'].get('overlap')
|
overlap = sym_attr['params'].get('overlap')
|
||||||
|
|
||||||
if scale_ratio_x != 1 or scale_ratio_y != 1:
|
if scale_ratio_x != 1 or scale_ratio_y != 1:
|
||||||
|
|
Loading…
Reference in a new issue