Bug 29008 - Clip doesn't work for text
Summary: Clip doesn't work for text
Status: RESOLVED FIXED
Alias: None
Product: cairo
Classification: Unclassified
Component: image backend (show other bugs)
Version: 1.9.10
Hardware: x86 (IA32) Linux (All)
: medium normal
Assignee: Carl Worth
QA Contact: cairo-bugs mailing list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-11 09:18 UTC by Igor Nikitin
Modified: 2010-07-12 08:53 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
result file (299 bytes, image/png)
2010-07-11 09:20 UTC, Igor Nikitin
Details
cairo_clip for complex area (187 bytes, image/png)
2010-07-12 07:08 UTC, Igor Nikitin
Details

Description Igor Nikitin 2010-07-11 09:18:45 UTC
#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;
}
Comment 1 Igor Nikitin 2010-07-11 09:20:10 UTC
Created attachment 36950 [details]
result file
Comment 2 Igor Nikitin 2010-07-12 07:01:19 UTC
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
Comment 3 Igor Nikitin 2010-07-12 07:08:23 UTC
Created attachment 36968 [details]
cairo_clip for complex area
Comment 4 Igor Nikitin 2010-07-12 08:01:55 UTC
more info again - for font 'terminus' complex clipping area also not work

P.S. Someone reads this? :)
Comment 5 Chris Wilson 2010-07-12 08:43:12 UTC
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
Comment 6 Igor Nikitin 2010-07-12 08:53:38 UTC
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.