#include <cairo/cairo.h> int main( int argc, char** argv ) { cairo_surface_t* surface = cairo_image_surface_create( CAIRO_FORMAT_ARGB32, 40, 15 ); cairo_t* target = cairo_create( surface ); // Height of region must by only 5 px cairo_rectangle( target, 0, 0, 40, 5 ); cairo_clip( target ); cairo_set_font_size( target, 12 ); cairo_select_font_face( target, "sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL ); cairo_set_source_rgb( target, 0, 0, 0 ); cairo_move_to( target, 0, 12 ); cairo_show_text( target, "TEST" ); cairo_stroke( target ); cairo_reset_clip( target ); cairo_surface_write_to_png( surface, "/home/igor/1.png" ); return 0; }
Created attachment 36950 [details] result file
more info - if use this code: cairo_rectangle( target, 0, 0, 40, 5 ); cairo_rectangle( target, 0, 7, 40, 1 ); clipping works fine, so seems here some wrong optimization for one rectangle
Created attachment 36968 [details] cairo_clip for complex area
more info again - for font 'terminus' complex clipping area also not work P.S. Someone reads this? :)
Igor, I've added your test case to the test suite using the permissive MIT license. Please let me know if you have any objections. commit ef0679333da881bd83b0bb4db546ea9c68f81f89 Author: Chris Wilson <chris@chris-wilson.co.uk> Date: Mon Jul 12 16:07:27 2010 +0100 image: Manually clip against bounds when rendering directly This is path is slightly peculiar in that it explicitly avoid the intermediate mask and the geometry is not pre-clipped. This in conjunction with the previous commit fixes: Clip doesn't work for text https://bugs.freedesktop.org/show_bug.cgi?id=29008 which is captured in test/partial-clip-text. commit 679e5a600bd7dae6cbde83070fb1f7355f8025a7 Author: Chris Wilson <chris@chris-wilson.co.uk> Date: Mon Jul 12 16:06:32 2010 +0100 Differentiate between reducing clip to composite extents and a rectangle This is required for handling glyphs when rendering directly to the surface. commit 8546a877889bfafc056c867bc9aea25e9fdcdef0 Author: Chris Wilson <chris@chris-wilson.co.uk> Date: Mon Jul 12 16:27:29 2010 +0100 test: Add partial-clip-text This exercises a bug found by Igor Nikitin: https://bugs.freedesktop.org/show_bug.cgi?id=29008
big thanks for fix
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.