![]() | ![]() | ![]() | 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
PangoFontMap | 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
|
PangoContext | 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
|
PangoLayout | 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
|
In the normal case, a PangoFontMap
created directly with
is all that is needed. A simple example that uses Pango to draw a string centered
in a page looks like: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
PangoFontMap* gnome_print_pango_font_map_new (void);
Creates a new gnome_print_pango_get_default_font_map()
instead.
Returns : | a newly created |
PangoFontMap* gnome_print_pango_get_default_font_map (void);
Gets a singleton
Returns : | the default |
PangoContext* gnome_print_pango_create_context (PangoFontMap *fontmap);
Creates a new
fontmap : | a |
Returns : | a newly created |
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
pango_layout_context_changed()
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.
context : | a |
gpc : |
PangoLayout* gnome_print_pango_create_layout (GnomePrintContext *gpc);
Convenience function that creates a new
gpc : | |
Returns : | the newly created |
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.
gpc : | |
font : | the |
glyphs : | a |
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.
gpc : | |
line : | a |
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.
gpc : | |
layout : | a |
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.
gpc : | |
pl : | the |
<<< gnome-print | gnome-print-unit >>> |