From 6c1a4bed4a94619898052bfe3bd03e1dfb71806f Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 9 Jan 2023 11:37:39 -0700 Subject: [PATCH] Better rounding clip boxes --- src/hb-font.hh | 4 ++-- src/hb-ft-colr.hh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/hb-font.hh b/src/hb-font.hh index 83f0d8701..8483507b9 100644 --- a/src/hb-font.hh +++ b/src/hb-font.hh @@ -184,8 +184,8 @@ struct hb_font_t { extents->x_bearing = em_scale_x (extents->x_bearing); extents->y_bearing = em_scale_y (extents->y_bearing); - extents->width = em_scale_x (extents->width); - extents->height = em_scale_y (extents->height); + extents->width = em_scale_x (extents->x_bearing + extents->width) - extents->x_bearing; + extents->height = em_scale_y (extents->y_bearing + extents->height) - extents->y_bearing; /* Apply slant. */ extents->x_bearing += roundf (extents->y_bearing * slant_xy); diff --git a/src/hb-ft-colr.hh b/src/hb-ft-colr.hh index 642897fd9..d74837c4d 100644 --- a/src/hb-ft-colr.hh +++ b/src/hb-ft-colr.hh @@ -447,9 +447,9 @@ hb_ft_paint_glyph_colr (hb_font_t *font, if (FT_Get_Color_Glyph_ClipBox (ft_face, gid, &clip_box)) { c.funcs->push_clip_rectangle (c.data, - clip_box.bottom_left.x - font->slant_xy * clip_box.bottom_left.y, + clip_box.bottom_left.x - roundf (font->slant_xy * clip_box.bottom_left.y), clip_box.bottom_left.y, - clip_box.top_right.x - font->slant_xy * clip_box.top_right.y, + clip_box.top_right.x - roundf (font->slant_xy * clip_box.top_right.y), clip_box.top_right.y); } else