[cairo] text to postscript rendering
Jürgen Ladstätter
info at innova-studios.com
Wed Mar 5 09:08:41 PST 2008
Hi there and thanks for your reply.
I'm using the attributes and set the details for a specific textrange as
follows:
/* creating empty PangoAttrList */
pal = pango_attr_list_new();
/**********************/
pfd = pango_font_description_from_string( "Comic Sans MS 20" );
/* creating new PangoAttribute for font description */
pa = pango_attr_font_desc_new(pfd);
pfc = pango_attr_foreground_new(65535,0,0);
/* we want to apply this font only to chars from 2 to 7 of text */
pa->start_index = 3;
pfc->start_index = 3;
pa->end_index = 7;
pfc->end_index = 7;
/* inserting attribute we created into the list */
pango_attr_list_insert(pal, pa);
pango_attr_list_insert(pal, pfc);
This works quite well, but I'm wondering if setting the fontsize behind the
name is stable or could face any problems.
Specifying a color for the textrange with pango_attr_foreground_new also
doesnt work. Printing the output into a png file, the text is always black,
not red.
Hope you have answers for me,
kind regards
-----Ursprüngliche Nachricht-----
Von: Kalle Vahlman [mailto:kalle.vahlman at gmail.com]
Gesendet: Freitag, 29. Februar 2008 11:24
An: info at innova-studios.com
Cc: Behdad Esfahbod; cairo at cairographics.org
Betreff: Re: [cairo] text to postscript rendering
2008/2/29, Jürgen Ladstätter <info at innova-studios.com>:
> Hi there again,
>
> i played a little bit with pango_cairo now and found no function for
using
> different fonts inside of a text. I could call the layout function
everytime
> i use a different font, but the text is then not drawn after the last
> characters. Is there any function that would do this?
What you are looking for is either Pango markup:
http://library.gnome.org/devel/pango/stable/PangoMarkupFormat.html
or text attributes (specifically the font related attributes):
http://library.gnome.org/devel/pango/stable/pango-Text-Attributes.html#id272
4863
Both allow you to change the font of a specified range of text, the
difference is that markup is simply text fragments inserted in the
string given to the layout while attributes are applied after the text
has been set to given character indexes. The markup in fact is
converted to attributes by pango, so usually attributes are the way to
go. At least in C where string handling sucks, on python for example
it's another story.
--
Kalle Vahlman, zuh at iki.fi
Powered by http://movial.fi
Interesting stuff at http://syslog.movial.fi
More information about the cairo
mailing list