[cairo] Font size issue when using pango + cairo

Emmanuel Pacaud emmanuel.pacaud at lapp.in2p3.fr
Tue Jan 6 05:41:33 PST 2009


Hi,

Le lundi 05 janvier 2009 à 17:02 -0500, Behdad Esfahbod a écrit :
> > A closer look shows that the glyphs rendered by gnumeric have a 9-pixel
> > cap height/digit height, are LCD optimized and look to have been pixel-
> > fit by glyf instructions.  The axis labels, OTOH, have a digit height of
> > 10 pixels and look to have been rendered w/o any hinting or pixel fitting
> > --certainly w/o use of instructions.  The large 10 under the chart has a
> > pixel height of 13 or 14 and was also rendered w/o instructions and,
> > again, probably w/o any hinting or pixel fitting.
> 
> Yeah, I'm guessing that Emmanuel is drawing the graph to an image surface and
> then copying to the X drawable?  You should instead create a surface using
> cairo_surface_create_similar(), such that font options are propagated
> correctly.  That should fix the hinting issue.

I don't really want to inheritate the font options, since I'd like to
obtain a layout that doesn't depend on the target, which can be either
an image or a vector surface.

> As for the size, I'm not sure what you're doing.  A 10 font size in pango is
> 10 points, and the dpi will come in when converting that to pixels.  The
> default 96dpi means a 96/72=1.33 scale factor, which explains the difference
> between 10px and 13px fonts.  You can either set dpi on the pango context
> (pango_cairo_context_set_resolution), or use absolute font sizes, either using
> pango_font_description_set_absolute_size, or the string syntax "10px" instead
> of "10".

That's the solution. I'm pretty sure I've already tried to use
pango_cairo_context_set_resolution before, but without success. Now, it
works.

Thanks a lot.

	Emmanuel.

-- 
Emmanuel PACAUD
Groupe Virgo
LAPP - Laboratoire d'Annecy-le-Vieux de physique des particules
9, chemin de Bellevue - BP 110
74941 Annecy-le-Vieux CEDEX
France
Tél: (+33)4 50 09 55 92 ou 17 89 - Fax: (+33)4 50 27 94 95



More information about the cairo mailing list