mirror of
https://github.com/ryanoasis/nerd-fonts.git
synced 2025-02-06 12:35:00 +02:00
font-patcher: Clarify height code
[why] Use of abs() looks like we do not know if the descenders are expected to be positive or negative. But it is well defined. Furthermore on abnormal fonts (where the descenders are nonexisting) we can use the wrong value. Well, that is academic I guess. [how] In our own `ymin` value we store a value like os2_descender, which means that it is on the same axis as the ascender (ymax). Typical values where the baseline is on y-coordinate 0 ymax will be positive and ymin (being below the baseline) will be negative. The total height has to be calculated from adding ascender + -descender (when the descenders are lower than the ascenders, which is guaranteed). The older descender values have positive values; are on an opposite y axis... The height with them would be ascender + descender. Well, WE have in the font_dim os2-like values... Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
This commit is contained in:
parent
4bca7849fe
commit
6f4af9482d
@ -876,7 +876,7 @@ class font_patcher:
|
||||
# print("New MAXWIDTH-B {} {} {}".format(glyph, self.sourceFont[glyph].width, xmax))
|
||||
|
||||
# Calculate font height
|
||||
self.font_dim['height'] = abs(self.font_dim['ymin']) + self.font_dim['ymax']
|
||||
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
|
||||
@ -886,7 +886,7 @@ class font_patcher:
|
||||
'xmax' : self.sourceFont.em,
|
||||
'ymax' : self.sourceFont.ascent,
|
||||
'width' : self.sourceFont.em,
|
||||
'height': abs(self.sourceFont.descent) + self.sourceFont.ascent,
|
||||
'height': self.sourceFont.descent + self.sourceFont.ascent,
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user