This repository was archived by the owner on Mar 7, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 174
LineSpacing font metric does not match with Windows #732
Copy link
Copy link
Open
Description
(Using libgdiplus built from main with Pango as backend)
For some fonts the vertical metric "line spacing" does not match between libgdiplus and GDI+. One example is Roboto Regular (which can be retrieved here: https://fonts.google.com/specimen/Roboto).
On Windows GDI+ reports the following metrics:
Ascent: 1946
Descent: 512
LineSpacing: 2458
On Linux libgdiplus reports the following metrics (for the same .ttf file):
Ascent: 1946
Descent: 512
LineSpacing: 2400
The reason for this seems to be that line spacing is set using ascender + descender + gap before ascender and descender are fully determined. Setting it afterwards results in the expected metrics:
diff --git a/src/font.c b/src/font.c
index 9a4ac3a..931ba4d 100644
--- a/src/font.c
+++ b/src/font.c
@@ -914,8 +914,6 @@ gdip_get_fontfamily_details_from_harfbuzz (GpFontFamily *family, hb_font_t *font
hb_font_set_scale (subfont, family->height, family->height);
hb_font_get_h_extents (subfont, &font_extents);
- family->linespacing = font_extents.line_gap + font_extents.ascender - font_extents.descender;
-
if (hb_ot_metrics_get_position (subfont, HB_OT_METRICS_TAG_HORIZONTAL_CLIPPING_ASCENT, &position)) {
family->cellascent = position;
} else {
@@ -927,6 +925,8 @@ gdip_get_fontfamily_details_from_harfbuzz (GpFontFamily *family, hb_font_t *font
family->celldescent = -font_extents.descender;
}
+ family->linespacing = font_extents.line_gap + family->cellascent + family->celldescent;
+
hb_font_destroy (subfont);
}
#endifMetadata
Metadata
Assignees
Labels
No labels