From 9c6b6998ef6edfb97323b10694e725b2665b505b Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 3 Mar 2025 11:46:22 -0700 Subject: [PATCH] [VARC] Fix sign of returned extents --- src/OT/Var/VARC/VARC.hh | 2 +- src/hb-geometry.hh | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/OT/Var/VARC/VARC.hh b/src/OT/Var/VARC/VARC.hh index b6f8aea81..ca9a59fd9 100644 --- a/src/OT/Var/VARC/VARC.hh +++ b/src/OT/Var/VARC/VARC.hh @@ -204,7 +204,7 @@ struct VARC release_scratch (scratch); if (ret) - *extents = f_extents.to_glyph_extents (); + *extents = f_extents.to_glyph_extents (font->x_scale < 0, font->y_scale < 0); return ret; } diff --git a/src/hb-geometry.hh b/src/hb-geometry.hh index 85ddd2abe..c22a26a40 100644 --- a/src/hb-geometry.hh +++ b/src/hb-geometry.hh @@ -85,13 +85,16 @@ struct hb_extents_t } } - hb_glyph_extents_t to_glyph_extents () const + hb_glyph_extents_t to_glyph_extents (bool xneg = false, bool yneg = false) const { hb_position_t x0 = (hb_position_t) roundf (xmin); hb_position_t y0 = (hb_position_t) roundf (ymin); hb_position_t x1 = (hb_position_t) roundf (xmax); hb_position_t y1 = (hb_position_t) roundf (ymax); - return hb_glyph_extents_t {x0, y0, x1 - x0, y1 - y0}; + return hb_glyph_extents_t {xneg ? x1 : x0, + yneg ? y0 : y1, + xneg ? x0 - x1 : x1 - x0, + yneg ? y1 - y0 : y0 - y1}; } float xmin = 0.f;