Fw: [cairo] Problem with fonts

Baptiste Gaillard b_gaillard at hotmail.com
Mon Jul 24 00:47:11 PDT 2006


Ok, the result is the same with the Vera font take from 
C:\Windows\fonts\Vera.ttf. I attach 2 files to this message, the first show 
the result using AGG, the second using Cairo, the font size is the same. But 
there is no anti-aliasing with Cairo !!

Here is the code I used:

int main(int argc, char** argv) {
 cairo_surface_t *surface;
  cairo_t *cr;

 surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, WIDTH, HEIGHT);
 cr = cairo_create (surface);


 cairo_set_source_rgb(cr, 1,1,1);
 cairo_set_line_width(cr, 1);
 cairo_set_antialias (cr,CAIRO_ANTIALIAS_GRAY);

 cairo_font_options_t* font_options =  cairo_font_options_create();
 cairo_font_options_set_antialias(font_options, CAIRO_ANTIALIAS_GRAY);
 cairo_set_font_options (cr, font_options);

 cairo_select_font_face (cr, "Vera.ttf", CAIRO_FONT_SLANT_NORMAL, 
CAIRO_FONT_WEIGHT_NORMAL);
 cairo_set_font_size (cr, 16);

 cairo_glyph_t glyph;
 glyph.index = 0x24;

 for(unsigned j = 0; j < 10000; j += 50)
  for(unsigned i = 0; i < 10000; i += 50) {
   cairo_move_to (cr, i, j);
   glyph.x = i;
   glyph.y = j;
   cairo_show_glyphs(cr, &glyph, 1);
  }

cairo_surface_write_to_png  (surface, "test.png");
cairo_font_options_destroy(font_options);
cairo_destroy (cr);
cairo_surface_destroy (surface);

return 0;
}

Thanks.

Baptiste

----- Original Message ----- 
From: "Behdad Esfahbod" <behdad at behdad.org>
To: "Baptiste Gaillard" <b_gaillard at hotmail.com>
Cc: <cairo at cairographics.org>
Sent: Friday, July 21, 2006 9:36 PM
Subject: Re: Fw: [cairo] Problem with fonts


> On Thu, 2006-07-20 at 06:47 -0400, Baptiste Gaillard wrote:
>> ----- Original Message ----- 
>> From: "Baptiste Gaillard" <b_gaillard at hotmail.com>
>> To: "Behdad Esfahbod" <behdad at behdad.org>
>> Sent: Thursday, July 20, 2006 9:52 AM
>> Subject: Re: [cairo] Problem with fonts
>>
>>
>> > Ok, I've seen an exemple here that use a 0.35 font size
>> > (http://cairographics.org/samples/text.html), so I think it is an 
>> > error.
>> > With size like 12-14-16 it works.
>
> Ah, not good.  Carl?
>
>> > But I've also anti-aliasing problem with the other options, I've tested
>> > with
>> > CAIRO_ANTIALIAS_GRAY and CAIRO_ANTIALIAS_SUBPIXEL but anti-aliased 
>> > seems
>> > again to be off. See the 2 files attached to this message, the first is 
>> > a
>> > symbol rendere with CAIRO_ANTIALIAS_GRAY, the second is rendered with
>> > CAIRO_ANTIALIAS_SUBPIXEL (is it normal that the contours are green ?).
>
> The green is kinda expected.  If it doesn't look good on your LCD, you
> may have a different RGB order, or a poor FreeType version.
>
> As for GRAY not working, is it the case that you are using a bitmap
> font?  Can you please try with a widely known font like Bitstream Vera
> and report the results of that?
>
> behdad
>
>> >
>> > Thanks.
>> >
>> > Baptiste.
>> >
>> _______________________________________________
>> cairo mailing list
>> cairo at cairographics.org
>> http://cairographics.org/cgi-bin/mailman/listinfo/cairo
> -- 
> behdad
> http://behdad.org/
>
> "Commandment Three says Do Not Kill, Amendment Two says Blood Will Spill"
>        -- Dan Bern, "New American Language"
>
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Cairo_A.png
Type: image/png
Size: 8298 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20060724/08e3bcd5/Cairo_A-0001.png
-------------- next part --------------
A non-text attachment was scrubbed...
Name: AGG_A.png
Type: image/png
Size: 9984 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20060724/08e3bcd5/AGG_A-0001.png


More information about the cairo mailing list