diff options
author | Matthias Clasen <mclasen@redhat.com> | 2021-12-09 19:40:07 +0000 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2021-12-09 19:40:07 +0000 |
commit | 9608a35bdd48e3961b8893a5789a1fcf592dbba0 (patch) | |
tree | 48e7bb143ae0abd4f062a948f7715fb8abed74a4 | |
parent | 2a3053e497d9396b525b88b78b413ebc484a6839 (diff) | |
parent | 2502562dd9ba30fd746bdf54a01e54dd11f87f30 (diff) | |
download | pango-9608a35bdd48e3961b8893a5789a1fcf592dbba0.tar.gz |
Merge branch 'broken-underlines' into 'main'
fc: Handle fonts with broken metrics better
Closes #616
See merge request GNOME/pango!537
-rw-r--r-- | pango/pangofc-font.c | 25 |
1 files 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 * |