Commit 2502562d authored by Matthias Clasen's avatar Matthias Clasen
Browse files

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
parent 8b46f5db
Pipeline #340682 passed with stages
in 7 minutes and 41 seconds
......@@ -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 *
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment