From 5c0112eff776611a17ad5f223ae7024c01d59f0e Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Sun, 2 Jul 2023 15:07:37 +0100 Subject: [PATCH] Account for rounding when subpixel positioning This is a workaround for the occasional clipping in scaled fonts with subpixel positioning. See: #390 Original patch by: Matthias Clasen --- src/cairo-scaled-font.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/cairo-scaled-font.c b/src/cairo-scaled-font.c index 75640f723..2a653a9a4 100755 --- a/src/cairo-scaled-font.c +++ b/src/cairo-scaled-font.c @@ -2232,6 +2232,11 @@ _cairo_scaled_font_single_glyph_device_extents (cairo_scaled_font_t *scaled_fon box.p2.y = v + scaled_glyph->bbox.p2.y; _cairo_box_round_to_rectangle (&box, extents); + + /* Modify the extents to account for the rounding */ + extents->y -= 1; + extents->width += 1; + extents->height += 1; } _cairo_scaled_font_thaw_cache (scaled_font); return status; @@ -2318,6 +2323,11 @@ _cairo_scaled_font_glyph_device_extents (cairo_scaled_font_t *scaled_font, if (box.p1.x < box.p2.x) { _cairo_box_round_to_rectangle (&box, extents); + + /* Modify the extents to account for the rounding */ + extents->y -= 1; + extents->width += 1; + extents->height += 1; } else { extents->x = extents->y = 0; extents->width = extents->height = 0; -- GitLab