mirror of
https://github.com/ryanoasis/nerd-fonts.git
synced 2025-01-25 03:32:02 +02:00
font-patcher: Use correct source font metrics
[why] With a source font where Win Ascent/Descent differs from Typo Ascend/Descent newly added symbols that are intended to be centered _within the visual space_ can end up too far up or down. The happens for example when patching CascadiaCode. Added glyphs like the Ubuntu logo (unicode 0xF31B) is not centered between the square brackets or on a line with the less then and other centered glyphs. [how] The calculation takes the Win Ascent/Descent to calculate the visual hight. That information is a mix of hight and line spacing and can be misleading. Therefore, if use_typo_metrics is set in a font, we obey that flag and use the typo metrics values instead. [note] Some websites with further information follow. https://github.com/googlefonts/gf-docs/tree/main/VerticalMetrics > Hhea metrics are used in Mac OS X, whilst Microsoft uses > Typo when Use_Typo_Metrics is enabled https://docs.microsoft.com/en-us/typography/opentype/otspec160/os2#fsselection https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6hhea.html Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
This commit is contained in:
parent
0692959e71
commit
ca26382644
@ -553,6 +553,9 @@ class font_patcher:
|
||||
self.sourceFont.os2_winascent += 1
|
||||
|
||||
# Make the line size identical for windows and mac
|
||||
# ! This is broken because hhea* is changed but os2_typo* is not
|
||||
# ! On the other hand we need intact (i.e. original) typo values
|
||||
# ! in get_sourcefont_dimensions() @TODO FIXME
|
||||
self.sourceFont.hhea_ascent = self.sourceFont.os2_winascent
|
||||
self.sourceFont.hhea_descent = -self.sourceFont.os2_windescent
|
||||
|
||||
@ -572,6 +575,9 @@ class font_patcher:
|
||||
'width' : 0,
|
||||
'height': 0,
|
||||
}
|
||||
if self.sourceFont.os2_use_typo_metrics:
|
||||
self.font_dim['ymin'] = self.sourceFont.os2_typodescent
|
||||
self.font_dim['ymax'] = self.sourceFont.os2_typoascent
|
||||
|
||||
# Find the biggest char width
|
||||
# Ignore the y-values, os2_winXXXXX values set above are used for line height
|
||||
|
Loading…
x
Reference in New Issue
Block a user