[cairo] Using Pango and TrueType Fonts

Michael Gerbracht smartmails at arcor.de
Fri Feb 20 09:25:33 PST 2015


Hello,

I would like to use Pango with Cairo to display data in graphs. As data
points I would like to use characters since there are a lot of symbols fonts
available which allow great flexibility. However I have three problem to
implement it correctly and I hope you can help me. (I could not find a
dedicated pango mailing list so if you thing there is a better list for this
question please tell me so).

I am using a pangocairo library for lua running on windows to generate the
graphics - this works in general. However, I still have theese problems:

First I noiced that I can display OpenType fonts but TrueType fonts are not
displayed (just a crossed out rectangle is shown instead). I am using the
pango_font_description_from_string method to set the font. Do I have to
convert TrueType fonts first?

Secondly I noticed that it is difficult to center the characters. As they
should represent a data point I would like to center the symbol at this
specific point. Currently I create a layout, set text and font description
and then use the get_size methode to read out the size. While this is not
completely wrong I often notice that it is not perfectly centered. Is there a
better way to get the dimension of a single character?

Finally I would like to be able to rotate the symbol. I can do this by
rotating the surface, drawing the character, and rotate back. But is this the
best way to do it or would you prefer another solution?

Sorry, I am quite new to Cairo und Pango but could not find the answers by
searching the web.

thanks a lot,
Michael



More information about the cairo mailing list