From a5ca8899e421a7a69023d8fb9616defb3fbf3c8a Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 22 Mar 2025 10:24:11 -0400 Subject: [PATCH] Optionally increase subpixel resolution Add CAIRO_SUBPIXEL_POSITIONS_FINE, for a 64x64 subpixel grid. This helps in GTK, where we found that a shift by 0.25 can be large enough to make the rasterized glyph touch new pixels, and that breaks our invalidation. --- src/cairo.h | 2 ++ src/cairoint.h | 1 + 2 files changed, 3 insertions(+) diff --git a/src/cairo.h b/src/cairo.h index c0ba973f7..23a02f605 100644 --- a/src/cairo.h +++ b/src/cairo.h @@ -1443,6 +1443,7 @@ typedef enum _cairo_color_mode { * the default manner for the font backend and target device, since 1.20 * @CAIRO_SUBPIXEL_POSITIONS_OFF: Do not use subpixel positions, since 1.20 * @CAIRO_SUBPIXEL_POSITIONS_ON: Use subpixel positions, since 1.20 + * @CAIRO_SUBPIXEL_POSITIONS_FINE: Use fine subpixel positions, since 1.20 * * Specifies whether to use subpixel positions when rendering glyphs. * Without subpixel positions, glyph positions will be rounded to pixels. @@ -1454,6 +1455,7 @@ typedef enum _cairo_subpixel_positions { CAIRO_SUBPIXEL_POSITIONS_DEFAULT, CAIRO_SUBPIXEL_POSITIONS_OFF, CAIRO_SUBPIXEL_POSITIONS_ON, + CAIRO_SUBPIXEL_POSITIONS_FINE } cairo_subpixel_positions_t; /** diff --git a/src/cairoint.h b/src/cairoint.h index 1552139da..20fc287b2 100644 --- a/src/cairoint.h +++ b/src/cairoint.h @@ -408,6 +408,7 @@ static inline int _cairo_subpixel_bits (cairo_subpixel_positions_t subpixel_posi [CAIRO_SUBPIXEL_POSITIONS_DEFAULT] = 2, [CAIRO_SUBPIXEL_POSITIONS_OFF] = 0, [CAIRO_SUBPIXEL_POSITIONS_ON] = 2, + [CAIRO_SUBPIXEL_POSITIONS_FINE] = 4, }; return bits[subpixel_positions];