So, I'm trying to set up a mask in Cairo, but can't make it have any meaning. Below I have a simple program based on this: http://snipplr.com/view/22584/cairo-hello-world-examble/ .
I set a fully transparent mask, so I donβt need to draw anything, but this seems to have no effect - the text is still drawn. My code is below. What am I missing?
Thank!
int main(int argc, char* argv[])
{
cairo_surface_t* surface;
cairo_t* cr;
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 200, 40);
cr = cairo_create (surface);
cairo_pattern_t* nothing = cairo_pattern_create_rgba(0,0,0,0);
cairo_mask (cr, nothing);
cairo_text_extents_t te;
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
cairo_select_font_face (cr, "Georgia",
CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size (cr, 20.0);
cairo_text_extents (cr, "hello cairo!", &te);
cairo_move_to (cr, 20, 20);
cairo_show_text (cr, "hello cairo!");
cairo_fill(cr);
cairo_surface_write_to_png(surface, "hello_cairo.png");
return 0;
}
Chris source
share