Clipping of subpixel anti-aliased text
Theo Veenker
theo.veenker at beexy.nl
Tue Apr 15 19:00:51 UTC 2025
Hi Ben,
You could check if cairo_text_path() followed by cairo_fill() yields a
different result? Probably not. I would test cairo_in_clip() on all
pixels for every loop iteration. Perhaps that shows the clip being
unexpectedly reset? Not sure.
Theo
--
Theo Veenker | Behavioral Experiment Systems
theo.veenker at beexy.nl | www.beexy.nl
On 14/04/2025 17:13, Ben Harris wrote:
> I have a question that essentially boils down to: if I set the clipping
> region to a pixel-aligned rectangle, should I expect pixels outside that
> rectangle to be unaffected by drawing operations?
>
> The specific example that leads me to ask this is demonstrated by the
> attached program. It creates a 20 × 20 pixel image surface sets the
> clipping region to precisely the left half of the surface, and then
> repeatedly shows a ']' character and then erases it using cairo_paint().
>
> My hope was that this would leave the whole image black because the last
> operation is to paint the entire clip region. But on my test systems
> (Debian bookworm and trixie, Cairo 1.16.0 and 1.18.4 respectively) I get
> a column of red pixels just outside the clipping rectangle.
>
> What is the expected behaviour here? I can see that for an arbitrary
> clipping region it's not possible to clip drawing operations in a way
> that can be perfectly undone. But in the special case of a pixel-
> aligned rectangle it should be possible. Or do I need to use
> cairo_surface_create_for_rectangle() to get perfect clipping?
>
> Aside: the context where I found this problem was the GTK version of the
> PuTTY terminal emulator, which needs to be able to reliably update only
> part of the terminal screen.
>
More information about the cairo
mailing list