Re: How to start using Pango?



Don't forget PangoMarkup:

  http://developer.gnome.org/doc/API/2.0/pango/PangoMarkupFormat.html

which provides a convenient shortcut for creating rich text layout with pango.

There are several examples of using pango without gtk in the pango
examples directory. A larger example is my paps program:
http://paps.sourceforge.net/ .

Regards,
Dov

On 3/4/07, Behdad Esfahbod <behdad behdad org> wrote:
On Fri, 2007-03-02 at 21:30 +0100, Jürgen Herz wrote:

> I'd appreciate some pointers or a short howto.

There are two ways to use pango, both need the following before anything
can be rendered:

  - A PangoFontMap.  This largely depends on the rendering technology
you want to use.  I highly recommend cairo.  In that case,
pango_cairo_font_map_get_default() gives you all you need.

  - A PangoContext.  You can create one in a fontmap-specific way.  For
PangoCairo, pango_cairo_font_map_create_context() does that.  Note that
with higher level code integrated with Pango, you typically just get the
context directly from higher level (gtk_widget_create_pango_context for
example).

With the PangoContext at hand, you have two choices to use Pango:

  - Use the PangoLayout object.  High-level, easy to use.  You don't
deal with PangoFonts directly.  Create a layout using pango_layout_new()
and set text and font-description on it.  Note that PangoCairo can
create one for you directly using pango_cairo_create_layout(), so does
Gtk+ using gtk_widget_create_layout().  Render a layout using
pango_cairo_show_layout().

  - Your other option, and that used by PangoLayout internally is to use
pango_itemize(), followed by pango_shape() on each resulting item, and
render the resulting glyphstrings using pango_cairo_show_glyph_string().


--
behdad
http://behdad.org/

"Those who would give up Essential Liberty to purchase a little
 Temporary Safety, deserve neither Liberty nor Safety."
        -- Benjamin Franklin, 1759



_______________________________________________
gtk-i18n-list mailing list
gtk-i18n-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-i18n-list




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]