From fa008a021fbd3c432499ac9316fa75a7f5a4ea02 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sun, 2 Jan 2022 10:46:38 -0700 Subject: [PATCH] [metrics] Implement synthetic slant for caret slope Part of https://github.com/harfbuzz/harfbuzz/pull/3338 --- src/hb-ot-metrics.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/hb-ot-metrics.cc b/src/hb-ot-metrics.cc index 4147ebe66..743a7f687 100644 --- a/src/hb-ot-metrics.cc +++ b/src/hb-ot-metrics.cc @@ -167,10 +167,18 @@ hb_ot_metrics_get_position (hb_font_t *font, unsigned rise = face->table.hhea->caretSlopeRise; unsigned upem = face->get_upem (); unsigned mult = rise < upem ? upem / rise : 1; + if (metrics_tag == HB_OT_METRICS_TAG_HORIZONTAL_CARET_RISE) return mult * GET_METRIC_Y (hhea, caretSlopeRise); else - return mult * GET_METRIC_X (hhea, caretSlopeRun); + { + unsigned run = mult * GET_METRIC_X (hhea, caretSlopeRun); + + if (font->slant) + run += _hb_roundf (mult * GET_METRIC_Y (hhea, caretSlopeRise) * font->slant); + + return run; + } } case HB_OT_METRICS_TAG_HORIZONTAL_CARET_OFFSET: return GET_METRIC_X (hhea, caretOffset);