[cairo] Toy text api, PNG, and magic numbers

Jonathan Kew jonathan at jfkew.plus.com
Wed Mar 25 16:42:10 PDT 2009


On 25 Mar 2009, at 23:19, Kozhevnikov Mikhail wrote:

> Hello,
>
> Smth goes wrong with the text rendered in the following example  
> (output attached)
>
>   cairo_surface_t *surface;
>   cairo_t *cr;
>   surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 600, 600);
>   cr = cairo_create(surface);
>   cairo_set_source_rgb(cr, 0, 0, 0);
>   cairo_select_font_face (cr, "Arial", CAIRO_FONT_SLANT_NORMAL,  
> CAIRO_FONT_WEIGHT_NORMAL);
>
>   const char* txt = "N";
>   cairo_set_font_size(cr, 10);
>   cairo_text_extents_t ext;
>   cairo_text_extents(cr, txt, &ext);
>   for (int j = 0; j < 50; ++j)
>      for (int i = 0; i < 50; ++i)
>      {
>         cairo_move_to(cr, (ext.width * (1.999 + j * 0.0005)) * i +  
> 20, j * 12 + 11);
>         cairo_show_text(cr, txt);
>      }
>
>   cairo_destroy(cr);
>   cairo_surface_write_to_png(surface, "test.png");
>   cairo_surface_destroy(surface);
>
> Looks interesting, ain't it? :)

Are you running on Windows, by any chance? If so, you might like to  
try the patch from here:

   http://mxr.mozilla.org/mozilla-central/source/gfx/cairo/win32-cleartype-clipping.patch?raw=1

and see if it makes any difference.

JK




More information about the cairo mailing list