Details
struct PangoLayout
The PangoLayout structure represents and entire paragraph
of text. It is initialized with a PangoContext, UTF-8 string
and set of attributes for that string. Once that is done, the
set of formatted lines can be extracted from the object,
the layout can be rendered, and conversion between logical
character positions within the layout's text, and the physical
position of the resulting glyphs can be made.
There are also a number of parameters to adjust the formatting
of a PangoLayout, which are illustrated in Figure 1.
It is possible, as well, to ignore the 2-D setup, and simply
treat the results of a PangoLayout as a list of lines.
The PangoLayout structure is opaque, and has no user-visible
fields.
pango_layout_new ()
Create a new PangoLayout object with attributes initialized to
default values for a particular PangoContext.
pango_layout_get_context ()
Retrieves the PangoContext used for this layout.
pango_layout_context_changed ()
void pango_layout_context_changed (PangoLayout *layout); |
Forces recomputation of any state in the PangoLayout that
might depend on the layout's context. This function should
be called if you make changes to the context subsequent
to creating the layout.
pango_layout_set_text ()
void pango_layout_set_text (PangoLayout *layout,
const char *text,
int length); |
Set the text of the layout.
pango_layout_set_attributes ()
Sets the text attributes for a layout object
pango_layout_set_font_description ()
Set the default font description for the layout. If no font
description is set on the layout, the font description from
the layout's context is used.
pango_layout_set_width ()
void pango_layout_set_width (PangoLayout *layout,
int width); |
Sets the width to which the lines of the PangoLayout should be wrapped.
pango_layout_get_width ()
Gets the width to which the lines of the PangoLayout should be wrapped.
pango_layout_set_indent ()
void pango_layout_set_indent (PangoLayout *layout,
int indent); |
Sets the amount of spacing between the lines of the layout.
pango_layout_get_indent ()
Gets the amount by which the first line should be shorter than the
rest of the lines.
pango_layout_get_spacing ()
Gets the amount of spacing between the lines of the layout.
pango_layout_set_spacing ()
void pango_layout_set_spacing (PangoLayout *layout,
int spacing); |
pango_layout_set_justify ()
void pango_layout_set_justify (PangoLayout *layout,
gboolean justify); |
Sets whether or not each complete line should be stretched to
fill the entire width of the layout. This stretching is typically
done by adding whitespace, but for some scripts (such as Arabic),
the justification is done by extending the characters.
pango_layout_get_justify ()
gboolean pango_layout_get_justify (PangoLayout *layout); |
Gets whether or not each complete line should be stretched to
fill the entire width of the layout.
pango_layout_set_alignment ()
Sets the alignment for the layout (how partial lines are
positioned within the horizontal space available.)
pango_layout_get_alignment ()
Sets the alignment for the layout (how partial lines are
positioned within the horizontal space available.)
enum PangoAlignment
typedef enum {
PANGO_ALIGN_LEFT,
PANGO_ALIGN_CENTER,
PANGO_ALIGN_RIGHT
} PangoAlignment; |
describes how to align the lines of a PangoLayout within the
available space. If the PangoLayout is set to justify
using pango_layout_set_justify(), then this only has an effect
for partial lines.
pango_layout_get_log_attrs ()
Retrieve an array of logical attributes for each character in
the layout.
pango_layout_xy_to_index ()
gboolean pango_layout_xy_to_index (PangoLayout *layout,
int x,
int y,
int *index,
gboolean *trailing); |
Convert from X and Y position within a layout to the byte
offset to the character at that logical position.
pango_layout_index_to_pos ()
Convert from an index within a PangoLayout to the onscreen position
corresponding to that character, which is represented as rectangle.
Note that pos->x is always the leading edge of the character. If the
and pos->x + pos->width the trailing edge of the character. If the
directionality of the character is right-to-left, then pos->width
will be negative.
pango_layout_get_cursor_pos ()
Given an index within a layout, determine the positions that of the
strong and weak cursors if the insertion point is at that
index. The position of each cursor is stored as a zero-width
rectangle. The strong cursor location is the location where
characters of the directionality equal to the base direction of the
layout are inserted. The weak cursor location is the location
where characters of the directionality opposite to the base
direction of the layout are inserted.
pango_layout_move_cursor_visually ()
void pango_layout_move_cursor_visually
(PangoLayout *layout,
int old_index,
int old_trailing,
int direction,
int *new_index,
int *new_trailing); |
Computes a new cursor position from an old position and
a count of positions to move visually. If count is positive,
then the new strong cursor position will be one position
to the right of the old cursor position. If count is position
then the new strong cursor position will be one position
to the left of the old cursor position.
In the presence of bidirection text, the correspondence
between logical and visual order will depend on the direction
of the current run, and there may be jumps when the cursor
is moved off of the end of a run.
pango_layout_get_extents ()
Compute the logical and ink extents of a layout. See the documentation
for pango_font_get_glyph_extents() for details about the interpretation
of the rectangles.
pango_layout_get_pixel_extents ()
Compute the logical and ink extents of a layout. See the documentation
for pango_font_get_glyph_extents() for details about the interpretation
of the rectangles. The returned rectangles are in device units, as
opposed to pango_layout_get_extents(), which returns the extents in
units of device unit / PANGO_SCALE.
pango_layout_get_size ()
void pango_layout_get_size (PangoLayout *layout,
int *width,
int *height); |
Determine the logical width and height of a PangoLayout
in Pango units. (device units divided by PANGO_SCALE). This
is simply a convenience function around pango_layout_get_extents.
pango_layout_get_pixel_size ()
void pango_layout_get_pixel_size (PangoLayout *layout,
int *width,
int *height); |
Determine the logical width and height of a PangoLayout
in device units. (pango_layout_get_size() returns the width
and height in thousandths of a device unit.) This
is simply a convenience function around pango_layout_get_extents.
pango_layout_get_line_count ()
Retrieve the count of lines for the PangoLayout
pango_layout_get_line ()
Retrieves a particular line from a PangoLayout
pango_layout_get_lines ()
Return the lines of the layout as a list
struct PangoLayoutLine
struct PangoLayoutLine
{
PangoLayout *layout;
gint length; /* length of line in bytes*/
GSList *runs;
}; |
The PangoLayoutLine structure represents one of the lines resulting
from laying out a paragraph via PangoLayout. PangoLayoutLine
structures are obtained by calling pango_layout_get_line() and
are only valid until the text, attributes, or settings of the
parent PangoLayout are modified.
Routines for rendering PangoLayout objects are provided in
code specific to each rendering system.
struct PangoLayoutRun
struct PangoLayoutRun
{
PangoItem *item;
PangoGlyphString *glyphs;
}; |
The PangoLayoutRun structure represents a single run within
a PangoLayoutLine.
pango_layout_line_ref ()
Increase the reference count of a PangoLayoutLine by one.
pango_layout_line_unref ()
Decrease the reference count of a PangoLayoutLine by one.
if the result is zero, the line and all associated memory
will be freed.
pango_layout_line_get_extents ()
Compute the logical and ink extents of a layout line. See the documentation
for pango_font_get_glyph_extents() for details about the interpretation
of the rectangles.
pango_layout_line_get_pixel_extents ()
Compute the logical and ink extents of a layout line. See the documentation
for pango_font_get_glyph_extents() for details about the interpretation
of the rectangles. The returned rectangles are in device units, as
opposed to pango_layout_line_get_extents(), which returns the extents in
units of device unit / PANGO_SCALE.
pango_layout_line_index_to_x ()
void pango_layout_line_index_to_x (PangoLayoutLine *line,
int index,
gboolean trailing,
int *x_pos); |
Convert index within a line to X pos
pango_layout_line_x_to_index ()
void pango_layout_line_x_to_index (PangoLayoutLine *line,
int x_pos,
int *index,
int *trailing); |
Convert from x offset to the byte index of the corresponding
character within the text of the layout. If the x_pos
is negative or greater than the length of the line, then
then the result will be 0, or the last index in the line
depending on the base direction of the layout.
pango_layout_line_get_x_ranges ()
void pango_layout_line_get_x_ranges (PangoLayoutLine *line,
int start_index,
int end_index,
int **ranges,
int *n_ranges); |
Get a list of visual ranges corresponding to a given logical range.
This list is not necessarily minimal - there may be consecutive
ranges which are adjacent. The ranges will be sorted from left to
right.