[cairo] Trouble with rendering antialiased string on surface
Marcin S
msporysz06 at gmail.com
Mon Dec 3 11:15:44 PST 2012
Hi guys,
I'm having a problem with drawing a text on image surface, here is example code
#include <cairo.h>
int main(int argc, char **argv)
{
cairo_surface_t* tar_surface =
cairo_image_surface_create(CAIRO_FORMAT_ARGB32,210,200);
cairo_t* ctx = cairo_create(tar_surface);
cairo_move_to(ctx,10,50);
cairo_font_options_t* cfo = cairo_font_options_create();
cairo_font_options_set_antialias(cfo,CAIRO_ANTIALIAS_SUBPIXEL);
cairo_set_font_options(ctx,cfo);
cairo_select_font_face(ctx,"Sans",CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size(ctx,40);
cairo_set_source_rgba(ctx,1,1,1,1);
cairo_show_text(ctx,"RAAWR");
cairo_move_to(ctx,10,150);
cairo_set_source_rgb(ctx,0,0,0);
cairo_show_text(ctx,"RAAWR");
cairo_surface_write_to_png(tar_surface,"pic.png");
return 0;
}
and pic genereated by it http://s8.postimage.org/9e67ndveb/pic.png
(it's printed on transparent bg)
Problem is that white string have some strange antialiasing color
(yellow), but black one is ok - any tips?
It's possible im doing something terribly wrong.
Marcin.
More information about the cairo
mailing list