Re: How to start using Pango?



On Fri, 2007-03-02 at 21:30 +0100, J�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






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