[cairo] Cairo's Arial font smaller than Arial in browsers

Ken Resander kresander at yahoo.com
Sun Mar 24 07:11:42 PDT 2013


I am using GTK3.0 and the Cairo that came with Ubuntu 12.04.

I am only just beginning with Cairo and have gone through the introductory tutorials and written some very tiny fragments to experiment and learn including the following for text:

   cairo_select_font_face(cr, "Arial", CAIRO_FONT_SLANT_NORMAL,
                          CAIRO_FONT_WEIGHT_NORMAL);
   cairo_set_font_size(cr, 12);   // <<<<< assume this is in pts
   cairo_set_source_rgb(cr, 0, 0, 0);
   const char * str = "This is text" ;
   cairo_font_extents_t fexts;
   cairo_font_extents ( cr, &fexts ) ;
   cairo_move_to(cr, 0,fexts.ascent);
   cairo_show_text(cr, str );

The text came out looking smaller than I had expected so I checked using Firefox, Chromium and Opera with the following tiny html file:

<style>
.some_class {
    padding: 0px;
    border: 2px solid green;
    }
</style>
<body>
<p class="some_class" style="font-family:Arial;font-size:12pt;">This is text</p>
</body>

The three browsers showed the text in exactly the same way. The height of the capital letter T was 12 pixels for the browsers and only 8 pixels for the Cairo output.

Why is this?

Ken
P.S. I was using screen capture and the GIMP Image Editor to view the pixels zooming 16x with a pixel grid.
The ascent and descent for the Cairo font choice were 11 and 3 respectively.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20130324/ee1d982c/attachment.html>


More information about the cairo mailing list