|  |  |  | GNOME Print Reference Manual |  | 
|---|---|---|---|---|
PangoFontMap* gnome_print_pango_font_map_new (void); PangoFontMap* gnome_print_pango_get_default_font_map (void); PangoContext* gnome_print_pango_create_context (PangoFontMap *fontmap); void gnome_print_pango_update_context (PangoContext *context, GnomePrintContext *gpc); PangoLayout* gnome_print_pango_create_layout (GnomePrintContext *gpc); void gnome_print_pango_glyph_string (GnomePrintContext *gpc, PangoFont *font, PangoGlyphString *glyphs); void gnome_print_pango_layout_line (GnomePrintContext *gpc, PangoLayoutLine *line); void gnome_print_pango_layout (GnomePrintContext *gpc, PangoLayout *layout); void gnome_print_pango_layout_print (GnomePrintContext *gpc, PangoLayout *pl);
The functions in this section allow you to use gnome-print to draw text using the sophisticated layout and internationalization capabilities of the Pango library. In general, for a GNOME application, these are the text APIs you should be using.
There are a number of different types of objects involved in using Pango with gnome-print.
| 
        A PangoFontMap contains
        the information necessary to resolve abstract font names
        to particular fonts on the system. A font map appropriate
        for use with gnome-print is created using
 | |
| 
        Information about doing layout for a particular output device
        with a particular set of options is
        encapsulated into a PangoContext. Contexts for
        gnome-print are created using
         
        A Pango context created in this way is not specific to a
        particular GnomePrintContext but
        before using a Pango context to do layout for a gnome-print
        context, it's necessary to call
         | |
| 
        A PangoLayout holds one or more paragraphs of text
        and encapsulates all the necessary logic needed to
        line wrap and lay out the text. Once you have a 
        PangoContext, you can create a layout using
         | 
In the normal case, a PangoFontMap
created directly with gnome_print_pango_create_layout()
static void
draw_hello_world (GnomePrintContext *gpc,
                  double             page_width,
                  double             page_height)
{
  PangoLayout *layout = gnome_print_pango_create_layout (gpc);
  int pango_width, pango_height;
  double width, height;
  pango_layout_set_text (layout, "Hello World");
  pango_layout_get_size (layout, &pango_width, &pango_height);
  width = (double) pango_width / PANGO_SCALE;
  height = (double) pango_height / PANGO_SCALE;
  gnome_print_moveto (gpc,
	             (page_width - width) / 2,
                     (page_width - height)/ 2);
  gnome_print_pango_layout (gpc, layout);
  g_object_unref (layout);
}
Note the need to convert from Pango units to the floating point
units that gnome-print uses by dividing by
PANGO_SCALE.
PangoFontMap* gnome_print_pango_font_map_new (void);
Creates a new PangoFontMap object suitable for use with
gnome-print. In most cases, you probably want to use
gnome_print_pango_get_default_font_map() instead.
| Returns : | a newly created PangoFontMap object | 
PangoFontMap* gnome_print_pango_get_default_font_map (void);
Gets a singleton PangoFontMap object suitable for use with gnome-print.
| Returns : | the default PangoFontMap object for gnome-print. The
returned object is owned by gnome-print and should not be modified.
(If you need to set custom options, create a new font map with gnome_print_pango_font_map_new().)  The reference count is
not increased. | 
PangoContext* gnome_print_pango_create_context (PangoFontMap *fontmap);
Creates a new PangoContext object for the specified fontmap.
| 
 | a PangoFontMap from gnome_print_pango_get_default_font_map()orgnome_print_pango_create_font_map(). | 
| Returns : | a newly created PangoContext object | 
void gnome_print_pango_update_context (PangoContext *context, GnomePrintContext *gpc);
Update a context so that layout done with it reflects the
current state of gpc. In general, every time you use a
PangoContext with a different GnomePrintContext, or
you change the transformation matrix of the GnomePrintContext
(other than pure translations) you should call this function.
You also need to call pango_layout_context_changed() for any
PangoLayout objects that exit for the PangoContext.
This function currently does nothing and that isn't expected to change for gnome-print. The main benefit of calling it is that your code will be properly prepared for conversion to use with future rendering systems such as Cairo where the corresponding operation will actually do something.
| 
 | a PangoContext from gnome_print_pango_create_context(). | 
| 
 | a GnomePrintContext | 
PangoLayout* gnome_print_pango_create_layout (GnomePrintContext *gpc);
Convenience function that creates a new PangoContext, updates
it for rendering to gpc, and then creates a PangoLayout for
that PangoContext. Generally this function suffices for
most usage of gnome-print with Pango and you don't need to
deal with the PangoContext directly.
| 
 | a GnomePrintContext | 
| Returns : | the newly created PangoLayout. Free with g_object_unref()when you are done with it. | 
void gnome_print_pango_glyph_string (GnomePrintContext *gpc, PangoFont *font, PangoGlyphString *glyphs);
Draws the glyphs in glyphs into the specified GnomePrintContext.
Positioning information in glyphs is transformed by the current
transformation matrix, the glyphs are drawn in the current color,
and the glyphs are positioned so that the left edge of the baseline
is at the current point.
| 
 | a GnomePrintContext | 
| 
 | the PangoFont that the glyphs in glyphsare from | 
| 
 | a PangoGlyphString | 
void gnome_print_pango_layout_line (GnomePrintContext *gpc, PangoLayoutLine *line);
Draws the text in line into the specified GnomePrintContext.  The
text is drawn in the current color unless that has been overridden
by attributes set on the layout and the glyphs are positioned so
that the left edge of the baseline is at the current point.
| 
 | a GnomePrintContext | 
| 
 | a PangoLayoutLine | 
void gnome_print_pango_layout (GnomePrintContext *gpc, PangoLayout *layout);
Draws the text in layout into the specified GnomePrintContext.  The
text is drawn in the current color unless that has been overridden
by attributes set on the layout and the glyphs are positioned so
that the left edge of the baseline is at the current point.
| 
 | a GnomePrintContext | 
| 
 | a PangoLayout | 
void gnome_print_pango_layout_print (GnomePrintContext *gpc, PangoLayout *pl);
Draws the text in pl into the specified GnomePrintContext.  The
text is drawn in the current color unless that has been overridden
by attributes set on the layout and the glyphs are positioned so
that the left edge of the baseline is at the point (0, 0). This function
is obsolete; use gnome_print_pango_layout() instead.
| 
 | a GnomePrintContext | 
| 
 | the PangoLayout to print |