[pango/broken-underlines] fc: Handle fonts with broken metrics better
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/broken-underlines] fc: Handle fonts with broken metrics better
- Date: Wed, 8 Dec 2021 11:47:33 +0000 (UTC)
commit 2502562dd9ba30fd746bdf54a01e54dd11f87f30
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Dec 8 06:44:29 2021 -0500
fc: Handle fonts with broken metrics better
It seems that some fonts don't have meaningful
values for underline and strikethrough metrics.
Ignore these font-provided values if they are zero.
Fixes: #616
pango/pangofc-font.c | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
---
diff --git a/pango/pangofc-font.c b/pango/pangofc-font.c
index 5635e0be..f29580c3 100644
--- a/pango/pangofc-font.c
+++ b/pango/pangofc-font.c
@@ -365,22 +365,29 @@ get_face_metrics (PangoFcFont *fcfont,
metrics->height = extents.ascender - extents.descender + extents.line_gap;
}
- metrics->underline_thickness = PANGO_SCALE;
- metrics->underline_position = - PANGO_SCALE;
- metrics->strikethrough_thickness = PANGO_SCALE;
- metrics->strikethrough_position = metrics->ascent / 2;
-
- if (hb_ot_metrics_get_position (hb_font, HB_OT_METRICS_TAG_UNDERLINE_SIZE, &position))
+ if (hb_ot_metrics_get_position (hb_font, HB_OT_METRICS_TAG_UNDERLINE_SIZE, &position) &&
+ position != 0)
metrics->underline_thickness = position;
+ else
+ metrics->underline_thickness = PANGO_SCALE;
- if (hb_ot_metrics_get_position (hb_font, HB_OT_METRICS_TAG_UNDERLINE_OFFSET, &position))
+ if (hb_ot_metrics_get_position (hb_font, HB_OT_METRICS_TAG_UNDERLINE_OFFSET, &position) &&
+ position != 0)
metrics->underline_position = position;
+ else
+ metrics->underline_position = - PANGO_SCALE;
- if (hb_ot_metrics_get_position (hb_font, HB_OT_METRICS_TAG_STRIKEOUT_SIZE, &position))
+ if (hb_ot_metrics_get_position (hb_font, HB_OT_METRICS_TAG_STRIKEOUT_SIZE, &position) &&
+ position != 0)
metrics->strikethrough_thickness = position;
+ else
+ metrics->strikethrough_thickness = PANGO_SCALE;
- if (hb_ot_metrics_get_position (hb_font, HB_OT_METRICS_TAG_STRIKEOUT_OFFSET, &position))
+ if (hb_ot_metrics_get_position (hb_font, HB_OT_METRICS_TAG_STRIKEOUT_OFFSET, &position) &&
+ position != 0)
metrics->strikethrough_position = position;
+ else
+ metrics->strikethrough_position = metrics->ascent / 2;
}
PangoFontMetrics *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]