[cairo] UTF-8 problem with cairo-show-text

Owen Taylor otaylor at redhat.com
Wed May 10 07:29:36 PDT 2006


On Wed, 2006-05-10 at 03:36 +0200, Christian Biesinger wrote:
> John Ellson wrote:
> > - Is there an API that will let me discover what exact font file, or font files, are being used for a
> > piece of text?    I'd like this for a debugging feature. 
> 
> After spending some time with the pango docs, it seems like you might 
> want to get each line from the pango layout (with pango_layout_get_line 
> maybe), then for each line get all the runs, whose item has an analysis 
> which contains a PangoFont.
> 
> I'm no pango expert, so there may be an easier way for this.

Yeah, that's pretty much the way you have to do it; dive down to
the individual runs, get the PangoFont, cast it to PangoFcFont,
and look at font->font_pattern (for which you'll have to #define
PANGO_ENABLE_BACKEND); you can get the file name as FC_FILE ... 
though if you just want the name of the selected font, you can:

 - run gucharmap
 - set the font to match what you are using in your program
 - right click on the character

And that will show you the font ... that doesn't take into account all
the details of the font assignment in Pango which looks at more than
single characters, but will handle simple cases like this one.

Regards,
						Owen




More information about the cairo mailing list