From d2aa2397bae6a6550060686da4cad1426eb2ad1f Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 9 Jan 2023 13:43:56 -0700 Subject: [PATCH] Optimize non-slant extents code --- src/hb-font.hh | 7 +++++-- src/hb-ft.cc | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/hb-font.hh b/src/hb-font.hh index 420e3919e..295972509 100644 --- a/src/hb-font.hh +++ b/src/hb-font.hh @@ -188,8 +188,11 @@ struct hb_font_t float y2 = em_fscale_y (extents->y_bearing + extents->height); /* Apply slant. */ - x1 += hb_min (y1 * slant_xy, y2 * slant_xy); - x2 += hb_max (y1 * slant_xy, y2 * slant_xy); + if (slant_xy) + { + x1 += hb_min (y1 * slant_xy, y2 * slant_xy); + x2 += hb_max (y1 * slant_xy, y2 * slant_xy); + } extents->x_bearing = floorf (x1); extents->y_bearing = floorf (y1); diff --git a/src/hb-ft.cc b/src/hb-ft.cc index e88276fae..34aa194c8 100644 --- a/src/hb-ft.cc +++ b/src/hb-ft.cc @@ -630,8 +630,11 @@ hb_ft_get_glyph_extents (hb_font_t *font, float y2 = y1 + y_mult * -ft_face->glyph->metrics.height; /* Apply slant. */ - x1 += hb_min (y1 * slant_xy, y2 * slant_xy); - x2 += hb_max (y1 * slant_xy, y2 * slant_xy); + if (slant_xy) + { + x1 += hb_min (y1 * slant_xy, y2 * slant_xy); + x2 += hb_max (y1 * slant_xy, y2 * slant_xy); + } extents->x_bearing = floorf (x1); extents->y_bearing = floorf (y1);