From 401cdf07922f66c762dabfd8e3d45c35e33de7c0 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 23 Oct 2018 17:00:49 -0700 Subject: [PATCH] [ot-font] Fix sign of ascent/descent Some fonts, like msmincho, have positive number as descent in vhea table. That's wrong. Just enforce sign on ascent/descent when reading both horizontal and vertical metrics. Fixes https://github.com/harfbuzz/harfbuzz/issues/1248 --- src/hb-ot-hmtx-table.hh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/hb-ot-hmtx-table.hh b/src/hb-ot-hmtx-table.hh index 5293fdada..935ddd720 100644 --- a/src/hb-ot-hmtx-table.hh +++ b/src/hb-ot-hmtx-table.hh @@ -199,8 +199,8 @@ struct hmtxvmtx #define USE_TYPO_METRICS (1u<<7) if (0 != (os2_table->fsSelection & USE_TYPO_METRICS)) { - ascender = os2_table->sTypoAscender; - descender = os2_table->sTypoDescender; + ascender = abs (os2_table->sTypoAscender); + descender = -abs (os2_table->sTypoDescender); line_gap = os2_table->sTypoLineGap; got_font_extents = (ascender | descender) != 0; } @@ -212,8 +212,8 @@ struct hmtxvmtx num_advances = _hea_table->numberOfLongMetrics; if (!got_font_extents) { - ascender = _hea_table->ascender; - descender = _hea_table->descender; + ascender = abs (_hea_table->ascender); + descender = -abs (_hea_table->descender); line_gap = _hea_table->lineGap; got_font_extents = (ascender | descender) != 0; }