Main Page Widgets Namespaces Book

# Pango::Layout Class Reference

Inheritance diagram for Pango::Layout:

[legend]
List of all members.

## Detailed Description

A Pango::Layout represents an 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.

## Public Member Functions

void | add_to_cairo_context (const Cairo::RefPtr<Cairo::Context>& context)
| Adds the text in this LayoutLine to the current path in the specified Cairo context.
void | context_changed ()
| Forces recomputation of any state in the Pango::Layout that might depend on the layout's context.
Glib::RefPtr<Layout> | copy ()
| Does a deep copy-by-value of the src layout.
Alignment | get_alignment () const
| Sets the alignment for the layout (how partial lines are positioned within the horizontal space available.
AttrList | get_attributes () const
| Gets the attribute list for the layout, if any.
bool | get_auto_dir () const
| Gets whether to calculate the bidirectional base direction for the layout according to the contents of the layout.
Glib::RefPtr<Context> | get_context () const
| Retrieves the Pango::Context used for this layout.
void | get_cursor_pos (int index, Rectangle& strong_pos, Rectangle& weak_pos) const
| Given an index within a layout, determines the positions that of the strong and weak cursors if the insertion point is at that index.
Rectangle | get_cursor_strong_pos (int index) const
| Given an index within the layout, determine the positions that of the strong cursors if the insertion point is at that index.
Rectangle | get_cursor_weak_pos (int index) const
| Given an index within the layout, determine the positions that of the weak cursors if the insertion point is at that index.
EllipsizeMode | get_ellipsize () const
| Gets the type of ellipsization being performed for layout .
void | get_extents (Rectangle& ink_rect, Rectangle& logical_rect) const
| Compute the logical and ink extents of layout .
FontDescription | get_font_description () const
| Gets the font description for the layout, if any.
int | get_indent () const
| Gets the paragraph indent width in pango units.
Rectangle | get_ink_extents () const
| Compute the ink extents of layout.
void | get_iter (LayoutIter& iter)
| Gets an iterator to iterate over the visual extents of the layout.
bool | get_justify () const
| Gets whether or not each complete line should be stretched to fill the entire width of the layout.
Glib::RefPtr<const LayoutLine> | get_line (int line) const
| Retrieves a particular line from a Pango::Layout.
Glib::RefPtr<LayoutLine> | get_line (int line)
| Retrieves a particular line from a Pango::Layout.
int | get_line_count () const
| Retrieves the count of lines for the layout .
SListHandle_ConstLayoutLine | get_lines () const
| Returns the lines of the layout as a list.
SListHandle_LayoutLine | get_lines ()
| Returns the lines of the layout as a list.
Glib::ArrayHandle<LogAttr> | get_log_attrs () const
| Retrieve an array of logical attributes for each character in the layout.
Rectangle | get_logical_extents () const
| Compute the logical extents of layout.
void | get_pixel_extents (Rectangle& ink_rect, Rectangle& logical_rect) const
| Compute the logical and ink extents of layout in device units.
Rectangle | get_pixel_ink_extents () const
| Compute the ink extents of the layout in device units.
Rectangle | get_pixel_logical_extents () const
| Compute the logical extents of the layout in device units.
void | get_pixel_size (int& width, int& height) const
| Determines the logical width and height of a Pango::Layout in device units.
bool | get_single_paragraph_mode () const
| Obtains the value set by pango_layout_set_single_paragraph_mode().
void | get_size (int& width, int& height) const
| Determines the logical width and height of a Pango::Layout in Pango units.
int | get_spacing () const
| Gets the amount of spacing between the lines of the layout.
TabArray | get_tabs () const
| Get the current Pango::TabArray used by this layout.
Glib::ustring | get_text () const
| Gets the text in the layout.
int | get_width () const
| Gets the width to which the lines of the Pango::Layout should be wrapped.
WrapMode | get_wrap () const
| Gets the wrap mode for the layout.
const PangoLayout* | gobj () const
| Provides access to the underlying C GObject.
PangoLayout* | gobj ()
| Provides access to the underlying C GObject.
PangoLayout* | gobj_copy ()
| Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
void | index_to_line_x (int index_, bool trailing, int& line, int& x_pos) const
| Converts from byte index within the layout to line and X position.
Rectangle | index_to_pos (int index) const
| Convert from an index within the layout to the onscreen position corresponding to the grapheme at that index, which is represented as rectangle.
void | 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.
void | set_alignment (Alignment alignment)
| Sets the alignment for the layout (how partial lines are positioned within the horizontal space available.
void | set_attributes (AttrList& attrs)
| Sets the text attributes for a layout object.
void | set_auto_dir (bool auto_dir=true)
| Sets whether to calculate the bidirectional base direction for the layout according to the contents of the layout; when this flag is on (the default), then paragraphs in layout that begin with strong right-to-left characters (Arabic and Hebrew principally), will have right-to-left layout, paragraphs with letters from other scripts will have left-to-right layout.
void | set_ellipsize (EllipsizeMode ellipsize)
| Sets the type of ellipsization being performed for layout .
void | set_font_description (const FontDescription& desc)
| Set the default font description for the layout.
void | set_indent (int indent)
| Sets the width in pango units to indent each paragraph.
void | set_justify (bool justify=true)
| Sets whether or not each complete line should be stretched to fill the entire width of the layout.
void | set_markup (const Glib::ustring& markup, gunichar accel_marker, gunichar& accel_char)
| Sets the layout text and attribute list from marked-up text (see markup format).
void | set_markup (const Glib::ustring& markup)
| Sets the layout text and attribute list from marked-up text (see markup format).
void | 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.
void | set_spacing (int spacing)
| Sets the amount of spacing between the lines of the layout.
void | set_tabs (TabArray& tabs)
| Sets the tabs to use for layout , overriding the default tabs (by default, tabs are every 8 spaces).
void | set_text (const Glib::ustring& text)
| Set the text of the layout.
void | set_width (int width)
| Sets the width to which the lines of the Pango::Layout should be wrapped.
void | set_wrap (WrapMode wrap)
| Sets the wrap mode; the wrap mode only has an effect if a width is set on the layout with pango_layout_set_width().
void | unset_font_description ()
void | update_from_cairo_context (const Cairo::RefPtr<Cairo::Context>& context)
| Updates the private Pango Context of a Pango Layout created with create(const Cairo::RefPtr<Cairo::Context>&) to match the current transformation and target surface of a Cairo Context.
bool | xy_to_index (int x, int y, int& index, int& trailing) const
| Converts from X and Y position within a layout to the byte index to the character at that logical position.
virtual | ~Layout ()

## Static Public Member Functions

static Glib::RefPtr<Layout> | create (const Cairo::RefPtr<Cairo::Context>& context)
| Creates a layout object set up to match the current transformation and target surface of the Cairo context.
static Glib::RefPtr<Layout> | create (const Glib::RefPtr<Context>& context)

## Protected Member Functions

| Layout (const Glib::RefPtr<Context>& context)

## Related Functions

(Note that these are not member functions.)
Glib::RefPtr<Pango::Layout> | wrap (PangoLayout* object, bool take_copy=false)
| A Glib::wrap() method for this object.

## Constructor & Destructor Documentation

virtual Pango::Layout::~Layout | ( |  | ) | `[virtual]`

Pango::Layout::Layout | ( | const Glib::RefPtr<Context>& | context | ) | `[explicit, protected]`

## Member Function Documentation

void Pango::Layout::add_to_cairo_context | ( | const Cairo::RefPtr< Cairo::Context > & | context | ) |

Adds the text in this LayoutLine to the current path in the specified Cairo context.

The origin of the glyphs (the left edge of the line) will be at the current point of the cairo context.

Parameters:

  | context | A Cairo context.

void Pango::Layout::context_changed | ( |  | ) |

Forces recomputation of any state in the Pango::Layout 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.

Glib::RefPtr<Layout> Pango::Layout::copy | ( |  | ) |

Does a deep copy-by-value of the src layout.

The attribute list, tab array, and text from the original layout are all copied by value.

Returns:
  A new Pango::Layout identical to src .

static Glib::RefPtr<Layout> Pango::Layout::create | ( | const Cairo::RefPtr< Cairo::Context > & | context | ) | `[static]`

Creates a layout object set up to match the current transformation and target surface of the Cairo context.

This layout can then be used for text measurement with functions like get_size() or drawing with methods like show_in_cairo_contet(). If you change the transformation or target surface for context, you need to call update_from_cairo_context()

This is the most convenient way to use Cairo with Pango. However it is slightly inefficient since it creates a separate Pango Context object for each layout. This might matter in an application that is laying out large amounts of text.

Parameters:

  | context | A Cairo context.

Returns:
  The newly created Pango Layout.

static Glib::RefPtr<Layout> Pango::Layout::create | ( | const Glib::RefPtr<Context>& | context | ) | `[static]`

Alignment Pango::Layout::get_alignment | ( |  | ) | const

Sets the alignment for the layout (how partial lines are positioned within the horizontal space available.

)

Returns:
  The alignment value.

AttrList Pango::Layout::get_attributes | ( |  | ) | const

Gets the attribute list for the layout, if any.

Returns:
  A Pango::AttrList.

bool Pango::Layout::get_auto_dir | ( |  | ) | const

Gets whether to calculate the bidirectional base direction for the layout according to the contents of the layout.

See pango_layout_set_auto_dir().

Returns:
  If `true`, the bidirectional base direction is computed from the layout's contents.

Glib::RefPtr<Context> Pango::Layout::get_context | ( |  | ) | const

Retrieves the Pango::Context used for this layout.

Returns:
  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.

void Pango::Layout::get_cursor_pos | ( | int | index,
|  | Rectangle& | strong_pos,
|  | Rectangle& | weak_pos |
| ) |  |  | const

Given an index within a layout, determines 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`).

Rectangle Pango::Layout::get_cursor_strong_pos | ( | int | index | ) | const

Given an index within the layout, determine the positions that of the strong cursors if the insertion point is at that index.

Parameters:

  | index | The byte index of the cursor.

Returns:
  The strong cursor position.

Rectangle Pango::Layout::get_cursor_weak_pos | ( | int | index | ) | const

Given an index within the layout, determine the positions that of the weak cursors if the insertion point is at that index.

Parameters:

  | index | The byte index of the cursor.

Returns:
  The weak cursor position.

EllipsizeMode Pango::Layout::get_ellipsize | ( |  | ) | const

Gets the type of ellipsization being performed for layout .

See pango_layout_set_ellipsize()

Returns:
  The current ellipsization mode for layout

Since: 1.6.

void Pango::Layout::get_extents | ( | Rectangle& | ink_rect,
|  | Rectangle& | logical_rect |
| ) |  |  | const

Compute the logical and ink extents of layout .

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.
  | logical_rect | Rectangle used to store the logical extents of the layout.

FontDescription Pango::Layout::get_font_description | ( |  | ) | const

Gets the font description for the layout, if any.

Returns:
  A pointer to the layout's font description, or `0` if the font description from the layout's context is inherited. This value is owned by the layout and must not be modified or freed.

int Pango::Layout::get_indent | ( |  | ) | const

Gets the paragraph indent width in pango units.

A negative value indicates a hanging indent.

Returns:
  The indent.

Rectangle Pango::Layout::get_ink_extents | ( |  | ) | const

Compute the ink extents of layout.

Returns:
  The extents of the layout as drawn.

void Pango::Layout::get_iter | ( | LayoutIter& | iter | ) |

Gets an iterator to iterate over the visual extents of the layout.

Parameters:

  | iter | Location to store the iterator.

bool Pango::Layout::get_justify | ( |  | ) | const

Gets whether or not each complete line should be stretched to fill the entire width of the layout.

Returns:
  The justify.

Glib::RefPtr<const LayoutLine> Pango::Layout::get_line | ( | int | line | ) | const

Retrieves a particular line from a Pango::Layout.

Parameters:

  | line | 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.

Glib::RefPtr<LayoutLine> Pango::Layout::get_line | ( | int | line | ) |

Retrieves a particular line from a Pango::Layout.

Parameters:

  | line | 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.

int Pango::Layout::get_line_count | ( |  | ) | const

Retrieves the count of lines for the layout .

Returns:
  The line count.

SListHandle_ConstLayoutLine Pango::Layout::get_lines | ( |  | ) | const

Returns the lines of the layout as a list.

Returns:
  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.

SListHandle_LayoutLine Pango::Layout::get_lines | ( |  | ) |

Returns the lines of the layout as a list.

Returns:
  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.

Glib::ArrayHandle<LogAttr> Pango::Layout::get_log_attrs | ( |  | ) | const

Retrieve an array of logical attributes for each character in the layout.

Returns:
  An array of logical attributes.

Rectangle Pango::Layout::get_logical_extents | ( |  | ) | const

Compute the logical extents of layout.

Returns:
  The logical extents of the layout.

void Pango::Layout::get_pixel_extents | ( | Rectangle& | ink_rect,
|  | Rectangle& | logical_rect |
| ) |  |  | const

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.
  | logical_rect | Rectangle used to store the logical extents of the layout.

Rectangle Pango::Layout::get_pixel_ink_extents | ( |  | ) | const

Compute the ink extents of the layout in device units.

Returns:
  The extents of the layout as drawn.

Rectangle Pango::Layout::get_pixel_logical_extents | ( |  | ) | const

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

Determines 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

Determines 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.

Returns:
  The spacing (in Pango::GlyphUnit).

TabArray Pango::Layout::get_tabs | ( |  | ) | const

Get the current Pango::TabArray used by this layout.

If no Pango::TabArray has been set, then the default tabs are in use and an invalid instance is returned. Default tabs are every 8 spaces.

Returns:
  A copy of the tabs for this layout.

Glib::ustring Pango::Layout::get_text | ( |  | ) | const

Gets the text in the layout.

The returned text should not be freed or modified.

Returns:
  The text in the layout .

int Pango::Layout::get_width | ( |  | ) | const

Gets the width to which the lines of the Pango::Layout should be wrapped.

Returns:
  The width.

WrapMode Pango::Layout::get_wrap | ( |  | ) | const

Gets the wrap mode for the layout.

Returns:
  Active wrap mode.

const PangoLayout* Pango::Layout::gobj | ( |  | ) | const`[inline]`

Provides access to the underlying C GObject.

Reimplemented from Glib::ObjectBase.

PangoLayout* Pango::Layout::gobj | ( |  | ) | `[inline]`

Provides access to the underlying C GObject.

Reimplemented from Glib::ObjectBase.

PangoLayout* Pango::Layout::gobj_copy | ( |  | ) |

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

void Pango::Layout::index_to_line_x | ( | int | index_,
|  | bool | trailing,
|  | int & | line,
|  | int & | x_pos |
| ) |  |  | const

Converts from byte index within the layout to line and X position.

(X position is measured from the left edge of the line)

Parameters:

  | index | The byte index of a grapheme within the layout.
  | trailing | An integer indicating the edge of the grapheme to retrieve the position of. If 0, the trailing edge of the grapheme, if > 0, the leading of the grapheme.
  | line | Location to store resulting line index. (which will between 0 and pango_layout_get_line_count(layout) - 1).
  | x_pos | Location to store resulting position within line (in thousandths of a device unit).

Rectangle Pango::Layout::index_to_pos | ( | int | index | ) | const

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.

void Pango::Layout::set_alignment | ( | Alignment | alignment | ) |

Sets the alignment for the layout (how partial lines are positioned within the horizontal space available.

)

Parameters:

  | alignment | The new alignment.

void Pango::Layout::set_attributes | ( | AttrList& | attrs | ) |

Sets the text attributes for a layout object.

Parameters:

  | attrs | A Pango::AttrList.

void Pango::Layout::set_auto_dir | ( | bool | auto_dir = `true` | ) |

Sets whether to calculate the bidirectional base direction for the layout according to the contents of the layout; when this flag is on (the default), then paragraphs in layout that begin with strong right-to-left characters (Arabic and Hebrew principally), will have right-to-left layout, paragraphs with letters from other scripts will have left-to-right layout.

Paragraphs with only neutral characters get their direction from the surrounding paragraphs.

When `false`, the choice between left-to-right and right-to-left layout is done by according to the base direction of the layout's Pango::Context. (See pango_context_set_base_dir()).

When the auto-computed direction or a paragraph differs from the base direction of the context, then the interpretation of Pango::ALIGN_LEFT and Pango::ALIGN_RIGHT are swapped.

Parameters:

  | auto_dir | If `true`, compute the bidirectional base direction from the layout's contents.

void Pango::Layout::set_ellipsize | ( | EllipsizeMode | ellipsize | ) |

Sets the type of ellipsization being performed for layout .

Depending on the ellipsization mode ellipsize text is removed from the start, middle, or end of lines so they fit within the width of layout set with pango_layout_set_width().

If the layout contains characters such as newlines that force it to be layed out in multiple lines, then each line is ellipsized separately.

Since: 1.6

Parameters:

  | ellipsize | The new ellipsization mode for layout .

void Pango::Layout::set_font_description | ( | const FontDescription& | desc | ) |

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.

Parameters:

  | desc | The new pango font description.

void Pango::Layout::set_indent | ( | int | indent | ) |

Sets the width in pango units to indent each paragraph.

A negative value of indent will produce a hanging indent. That is, the first line will have the full width, and subsequent lines will be indented by the absolute value of indent .

Parameters:

  | indent | The amount by which to indentset.

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.

Note that as of Pango-1.4, this functionality is not yet implemented.

Parameters:

  | justify | Whether the lines in the layout should be justified.

void Pango::Layout::set_markup | ( | const Glib::ustring & | markup,
|  | gunichar | accel_marker,
|  | gunichar & | accel_char |
| ) |  |  |

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.

Parameters:

  | markup | Some marked-up text.
  | accel_marker | Marker for accelerators in the text.
  | accel_char | Return location for any located accelerators.

void Pango::Layout::set_markup | ( | const Glib::ustring & | markup | ) |

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.

Parameters:

  | spacing | The amount of spacing.

void Pango::Layout::set_tabs | ( | TabArray& | tabs | ) |

Sets the tabs to use for layout , overriding the default tabs (by default, tabs are every 8 spaces).

If tabs is `0`, the default tabs are reinstated. tabs is copied into the layout; you must free your copy of tabs yourself.

Parameters:

  | tabs | A Pango::TabArray.

void Pango::Layout::set_text | ( | const Glib::ustring & | text | ) |

Set the text of the layout.

Parameters:

  | text | The text for the layout.

void Pango::Layout::set_width | ( | int | width | ) |

Sets the width to which the lines of the Pango::Layout should be wrapped.

Parameters:

  | width | The desired width, or -1 to indicate that no wrapping should be performed.

void Pango::Layout::set_wrap | ( | WrapMode | wrap | ) |

Sets the wrap mode; the wrap mode 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 | The wrap mode.

void Pango::Layout::unset_font_description | ( |  | ) |

void Pango::Layout::update_from_cairo_context | ( | const Cairo::RefPtr< Cairo::Context > & | context | ) |

Updates the private Pango Context of a Pango Layout created with create(const Cairo::RefPtr<Cairo::Context>&) to match the current transformation and target surface of a Cairo Context.

Parameters:

  | context | A Cairo context.

bool Pango::Layout::xy_to_index | ( | int | x,
|  | int | y,
|  | int & | index,
|  | int & | trailing |
| ) |  |  | const

Converts from X and Y position within a layout to the byte index to the character at that logical position.

If the Y position is not inside the layout, the closest position is chosen (the position will be clamped inside the layout). If the X position is not within the layout, then the start or the end of the line is chosen as described for pango_layout_x_to_index(). If either the X or Y positions were not inside the layout, then the function returns `false`; on an exact hit, it returns `true`.

Parameters:

  | x | The X offset (in Pango::GlyphUnit) from the left edge of the layout.
  | y | The Y offset (in Pango::GlyphUnit) 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.

Returns:
  `true` if the coordinates were inside text.

## Friends And Related Function Documentation

Glib::RefPtr<Pango::Layout> wrap | ( | PangoLayout * | object,
|  | bool | take_copy = `false` |
| ) |  |  | `[related]`

A Glib::wrap() method for this object.

Parameters:

  | object | The C instance.
  | take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref.

Returns:
  A C++ instance that wraps this C instance.

The documentation for this class was generated from the following file:

- pango/pangomm/layout.h