From fc329f665fab56c2983ababf2ebc71088b2ecfcc Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sun, 2 Jan 2022 10:41:41 -0700 Subject: [PATCH] [metrics] Scale up horizontal caret rise/run Eg. if rise/run are 1/0, we now return upem/0. This is equivalent. Part of https://github.com/harfbuzz/harfbuzz/pull/3338 --- src/hb-ot-metrics.cc | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/hb-ot-metrics.cc b/src/hb-ot-metrics.cc index dbd4a1ffb..4147ebe66 100644 --- a/src/hb-ot-metrics.cc +++ b/src/hb-ot-metrics.cc @@ -160,9 +160,20 @@ hb_ot_metrics_get_position (hb_font_t *font, (position && (*position = font->em_scalef_y (face->table.TABLE->ATTR + GET_VAR)), true)) case HB_OT_METRICS_TAG_HORIZONTAL_CLIPPING_ASCENT: return GET_METRIC_Y (OS2, usWinAscent); case HB_OT_METRICS_TAG_HORIZONTAL_CLIPPING_DESCENT: return GET_METRIC_Y (OS2, usWinDescent); - case HB_OT_METRICS_TAG_HORIZONTAL_CARET_RISE: return GET_METRIC_Y (hhea, caretSlopeRise); - case HB_OT_METRICS_TAG_HORIZONTAL_CARET_RUN: return GET_METRIC_X (hhea, caretSlopeRun); + + case HB_OT_METRICS_TAG_HORIZONTAL_CARET_RISE: + case HB_OT_METRICS_TAG_HORIZONTAL_CARET_RUN: + { + 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); + } case HB_OT_METRICS_TAG_HORIZONTAL_CARET_OFFSET: return GET_METRIC_X (hhea, caretOffset); + #ifndef HB_NO_VERTICAL case HB_OT_METRICS_TAG_VERTICAL_CARET_RISE: return GET_METRIC_X (vhea, caretSlopeRise); case HB_OT_METRICS_TAG_VERTICAL_CARET_RUN: return GET_METRIC_Y (vhea, caretSlopeRun);