mirror of
https://github.com/ryanoasis/nerd-fonts.git
synced 2025-01-25 03:32:02 +02:00
font-patcher: Fix empty input font detection
[why] If we have an empty input font (i.e. for Symbols Only font) and that font has a gap.. That gap will be redistributed to a gapless font where the ascenders and descenders are expanded to fill/keep the gap. If the font has no height (i.e. == ) and a gap, the height will afterwards be > 0 and the empty font detection breaks. [how] Detect empty fonts before gaps. Fixes: #965 Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
This commit is contained in:
parent
6f4af9482d
commit
3e478f7cf8
29
font-patcher
29
font-patcher
@ -840,6 +840,20 @@ class font_patcher:
|
||||
self.font_dim['ymin'] = self.sourceFont.os2_typodescent
|
||||
self.font_dim['ymax'] = self.sourceFont.os2_typoascent
|
||||
|
||||
# Calculate font height
|
||||
self.font_dim['height'] = -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
|
||||
self.font_dim = {
|
||||
'xmin' : 0,
|
||||
'ymin' : -self.sourceFont.descent,
|
||||
'xmax' : self.sourceFont.em,
|
||||
'ymax' : self.sourceFont.ascent,
|
||||
'width' : self.sourceFont.em,
|
||||
'height': self.sourceFont.descent + self.sourceFont.ascent,
|
||||
}
|
||||
|
||||
# Line gap add extra space on the bottom of the line which
|
||||
# doesn't allow the powerline glyphs to fill the entire line.
|
||||
# Put half of the gap into the 'cell', each top and bottom
|
||||
@ -853,6 +867,7 @@ class font_patcher:
|
||||
gap_bottom = gap - gap_top
|
||||
self.font_dim['ymin'] -= gap_bottom
|
||||
self.font_dim['ymax'] += gap_top
|
||||
self.font_dim['height'] = -self.font_dim['ymin'] + self.font_dim['ymax']
|
||||
self.sourceFont.os2_typoascent = self.sourceFont.os2_typoascent + gap_top
|
||||
self.sourceFont.os2_typodescent = self.sourceFont.os2_typodescent - gap_bottom
|
||||
# TODO Check what to do with win and hhea values
|
||||
@ -875,20 +890,6 @@ class font_patcher:
|
||||
self.font_dim['xmax'] = xmax
|
||||
# print("New MAXWIDTH-B {} {} {}".format(glyph, self.sourceFont[glyph].width, xmax))
|
||||
|
||||
# Calculate font height
|
||||
self.font_dim['height'] = -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
|
||||
self.font_dim = {
|
||||
'xmin' : 0,
|
||||
'ymin' : -self.sourceFont.descent,
|
||||
'xmax' : self.sourceFont.em,
|
||||
'ymax' : self.sourceFont.ascent,
|
||||
'width' : self.sourceFont.em,
|
||||
'height': self.sourceFont.descent + self.sourceFont.ascent,
|
||||
}
|
||||
|
||||
|
||||
def get_scale_factor(self, sym_dim):
|
||||
scale_ratio = 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user