If setting is true, do not treat newlines and similar characters as paragraph separators; instead, keep all text in a single paragraph, and display a glyph for paragraph separator characters.
A Pango::Layout represents and entire paragraph of text.
It is initialized with a Pango::Context, 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.
The Pango::Context for the layout. This does not have an additional refcount added, so if you want to keep a copy of this around, you must reference it yourself.
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.
Parameters:
index_
The byte index of the cursor.
strong_pos
Location to store the strong cursor position (may be 0).
weak_pos
Location to store the weak cursor position (may be 0).
Logical extents are usually what you want for positioning things. The extents are given in layout coordinates; layout coordinates begin at the top left corner of the layout.
Parameters:
ink_rect
Rectangle used to store the extents of the layout as drawn or 0 to indicate that the result is not needed.
logical_rect
Rectangle used to store the logical extents of the layout or 0 to indicate that the result is not needed.
int Pango::Layout::get_indent
(
)
const
Gets the amount by which the first line should be shorter than the rest of the lines.
The index of a line, which must be between 0 and pango_layout_get_line_count(layout) - 1, inclusive.
Returns:
The requested Pango::LayoutLine, or 0 if the index is out of range. This layout line can be ref'ed and retained, but will become invalid if changes are made to the Pango::Layout.
A G::SList containing the lines in the layout. This points to internal data of the Pango::Layout and must be used with care. It will become invalid on any change to the layout's text or properties.
Compute the logical and ink extents of layout in device units.
See pango_layout_get_extents(); this function just calls pango_layout_get_extents() and then converts the extents to pixels using the Pango::SCALE factor.
Parameters:
ink_rect
Rectangle used to store the extents of the layout as drawn or 0 to indicate that the result is not needed.
logical_rect
Rectangle used to store the logical extents of the layout or 0 to indicate that the result is not needed.
Compute the logical extents of the layout in device units.
Returns:
The logical extents of the layout.
void Pango::Layout::get_pixel_size
(
int&
width,
int&
height
)
const
Determine the logical width and height of a Pango::Layout 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.
Parameters:
width
Location to store the logical width, or 0.
height
Location to store the logical height, or 0.
bool Pango::Layout::get_single_paragraph_mode
(
)
const
Obtains the value set by pango_layout_set_single_paragraph_mode().
Returns:
true if the layout does not break paragraphs at paragraph separator characters.
void Pango::Layout::get_size
(
int&
width,
int&
height
)
const
Determine the logical width and height of a Pango::Layout in Pango units.
(device units divided by PANGO_SCALE). This is simply a convenience function around pango_layout_get_extents.
Parameters:
width
Location to store the logical width, or 0.
height
Location to store the logical height, or 0.
int Pango::Layout::get_spacing
(
)
const
Gets the amount of spacing between the lines of the layout.
If no Pango::TabArray has been set, then the default tabs are in use and 0 is returned. Default tabs are every 8 spaces. The return value should be freed with pango_tab_array_free().
Convert from an index within the layout to the onscreen position corresponding to the grapheme at that index, which is represented as rectangle.
Note that x in the returned rectangle is always the leading edge of the grapheme and x + width the trailing edge of the grapheme. If the directionality of the grapheme is right-to-left, then width will be negative.
Parameters:
index
Byte index within layout.
Returns:
The position of the grapheme.
void Pango::Layout::move_cursor_visually
(
bool
strong,
int
old_index,
int
old_trailing,
int
direction,
int&
new_index,
int&
new_trailing
)
const
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.
Motion here is in cursor positions, not in characters, so a single call to pango_layout_move_cursor_visually() may move the cursor over multiple characters when multiple characters combine to form a single grapheme.
Parameters:
strong
Whether the moving cursor is the strong cursor or the weak cursor. The strong cursor is the cursor corresponding to text insertion in the base direction for the layout.
old_index
The byte index of the grapheme for the old index.
old_trailing
If 0, the cursor was at the trailing edge of the grapheme indicated by old_index , if > 0, the cursor was at the leading edge.
direction
Direction to move cursor. A negative value indicates motion to the left.
new_index
Location to store the new cursor byte index. A value of -1 indicates that the cursor has been moved off the beginning of the layout. A value of G_MAXINT indicates that the cursor has been moved off the end of the layout.
new_trailing
Number of characters to move forward from the location returned for new_index to get the position where the cursor should be displayed. This allows distinguishing the position at the beginning of one line from the position at the end of the preceding line. new_index is always on the line where the cursor should be displayed.
If no font description is set on the layout, the font description from the layout's context is used.
Parameters:
desc
The new pango font description, or 0 to unset the current font description.
void Pango::Layout::set_indent
(
int
indent
)
Sets the amount by which the first line should be shorter than the rest of the lines.
This may be negative, in which case the subsequent lines will be shorter than the first line. (However, in either case, the entire width of the layout will be given by the value
Parameters:
indent
The amount by which to indent.
void Pango::Layout::set_justify
(
bool
justify = true
)
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.
Parameters:
justify
Whether the lines in the layout should be justified.
Sets the layout text and attribute list from marked-up text (see markup format).
Replaces the current text and attribute list.
If accel_marker is nonzero, the given character will mark the character following it as an accelerator. For example, the accel marker might be an ampersand or underscore. All characters marked as an accelerator will receive a Pango::UNDERLINE_LOW attribute, and the first character so marked will be returned in accel_char. Two accel_marker characters following each other produce a single literal accel_marker character.
Sets the layout text and attribute list from marked-up text (see markup format).
Replaces the current text and attribute list.
Parameters:
markup
Some marked-up text.
void Pango::Layout::set_single_paragraph_mode
(
bool
setting = true
)
If setting is true, do not treat newlines and similar characters as paragraph separators; instead, keep all text in a single paragraph, and display a glyph for paragraph separator characters.
Used when you want to allow editing of newlines on a single text line.
Parameters:
setting
New setting.
void Pango::Layout::set_spacing
(
int
spacing
)
Sets the amount of spacing between the lines of the layout.
Sets the wrap style; the wrap style only has an effect if a width is set on the layout with pango_layout_set_width().
To turn off wrapping, set the width to -1.
Parameters:
wrap
Wrap mode.
bool Pango::Layout::xy_to_index
(
int
x,
int
y,
int&
index,
int&
trailing
)
const
Convert from X and Y position within a layout to the byte index to the character at that logical position.
If the position is not inside the layout, the closest position is chosen (the x/y position will be clamped inside the layout). If a closest position is chosen, then the function returns false; on an exact hit, it returns true.
Parameters:
x
The X offset (in thousandths of a device unit) from the left edge of the layout.
y
The Y offset (in thousandths of a device unit) from the top edge of the layout.
index_
Location to store calculated byte index.
trailing
Location to store a integer indicating where in the grapheme the user clicked. It will either be zero, or the number of characters in the grapheme. 0 represents the trailing edge of the grapheme.