新規作成  編集  Ruby-GNOME2 Project Website  ページ一覧  検索  更新履歴  編集履歴  RSS  ログイン

Pango::Layout

class Pango::Layout

The Pango::Layout class 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.

There are also a number of parameters to adjust the formatting of a Pango::Layout, which are illustrated in Figure 1, Adjustable parameters for a Pango::Layout. It is possible, as well, to ignore the 2-D setup, and simply treat the results of a Pango::Layout as a list of lines.

Figure 1. Adjustable parameters for a Pango::Layout

<URL:http://developer.gnome.org/doc/API/2.0/pango/layout.gif>

Class Methods

Pango::Layout.new
Create a new Pango::Layout object with attributes initialized to default values for a particular Pango::Context.

Instance Methods

context
Retrieves the Pango::Context used for this layout.
context_changed
Forces recomputation of any state in the Pango::Layout that might depend on the layout's context. This method should be called if you make changes to the context subsequent to creating the layout.
  • Returns: self
text
Gets the text in the layout.
  • Returns: the text in the layout
text=(text)
Sets the text of the layout.
  • text: a UTF-8 string
  • Returns: self
set_text(text)
Same as Pango::Layout#text=.
  • text: a UTF-8 string
  • Returns: self
markup=(markup)
Same as Pango::Layout#set_markup(markup, nil).
  • markup: some marked-up text (see markup format)
  • Returns: any located accelerators
set_markup(markup, accel_marker = nil)
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 non-nil, 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 value. Two accel_marker characters following each other produce a single literal accel_marker character.
  • markup: some marked-up text (see markup format)
  • accel_marker : marker for accelerators in the text or nil
  • Returns: any located accelerators
attributes
Gets the attribute list for the layout, if any.
  • Returns : a Pango::AttrList?
attributes=(attrs)
Sets the text attributes for a layout object.
  • attrs : a Pango::AttrList?
  • Returns: attrs
set_attributes(attrs)
Same as Pango::Layout#attributes=
  • attrs : a Pango::AttrList?
  • Returns: self
font_description
Gets the font description for the layout, if any.
  • Returns: the layout's font description(Pango::FontDescription), or nil if the font description from the layout's context is inherited.
font_description=(desc)
Sets 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.
set_font_description(desc)
Same as Pango::Layout#font_description=.
width
Gets the width to which the lines of the Pango::Layout should be wrapped.
  • Returns: the width
width=(width)
Sets the width to which the lines of the Pango::Layout should be wrapped.
  • width : the desired width, or -1 to indicate that no wrapping should be performed.
  • Returns: width
set_width(width)
Same as Pango::Layout#width=.
  • width: the desired width, or -1 to indicate that no wrapping should be performed.
  • Returns: self
wrap
Gets the wrap mode for the layout.
wrap=(wrap)
Sets the wrap mode; the wrap mode only has an effect if a width is set on the layout with Pango::Layout#width=. To turn off wrapping, set the width to -1.
set_wrap(wrap)
Same as Pango::Layout#wrap=.
ellipsize
Gets the type of ellipsization being performed for layout. See Pango::Layout#ellipsize=.
ellipsize=(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#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
set_ellipsize(ellipsize)
Same as Pango::Layout#ellipsize=. Since 1.6
indent
Gets the paragraph indent width in pango units. A negative value indicates a hanging indent.
  • Returns: the indent
indent=(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.
  • indent: the amount by which to indentset (Integer)
  • Returns: indent
set_indent(indent)
Same as Pango::Layout#indent=.
  • indent: the amount by which to indentset (Integer)
  • Returns: self
spacing
Gets the amount of spacing between the lines of the layout.
  • Returns: the spacing (in Pango::GlyphUnit?) FIXME
spacing=(spacing)
  • Returns: self
set_spacing(spacing)
  • Returns: self
alignment
  • Returns: self
alignment=
  • Returns: self
set_alignment
  • Returns: self
auto_dir?
  • Returns: self
auto_dir=(auto_dir)
  • Returns: self
set_auto_dir(auto_dir)
Same as Pango::Layout#auto_dir=.
  • Returns: self
copy
  • Returns: self
extents
  • Returns: self
get_clip_region
  • Returns: self
get_cursor_pos
  • Returns: self
get_extents
  • Returns: self
get_line
  • Returns: self
get_pixel_extents
  • Returns: self
index_to_pos
  • Returns: self
iter
  • Returns: self
justify?
  • Returns: self
justify=
  • Returns: self
set_justify
Same as Pango::Layout#justify=.
  • Returns: self
line_count
  • Returns: self
lines
  • Returns: self
log_attrs
  • Returns: self
move_cursor_visually
  • Returns: self
pixel_extents
  • Returns: self
pixel_size
  • Returns: self
set_single_paragraph_mode
  • Returns: self
single_paragraph_mode=
  • Returns: self
single_paragraph_mode?
  • Returns: self
size
  • Returns: self
tabs
  • Returns: self
tabs=(tabs)
  • Returns: self
set_tabs(tabs)
Same as Pango::Layout#tabs=.
  • Returns: self
xy_to_index
  • Returns: self

Constants

WrapMode

A WrapMode describes how to wrap the lines of a Pango::Layout to the desired width.

WRAP_WORD
wrap lines at word boundaries.
WRAP_CHAR
wrap lines at character boundaries.
WRAP_WORD_CHAR
wrap lines at word boundaries, but fall back to character boundaries if there is not enough space for a full word.

EllipsizeMode

The EllipsizeMode type describes what sort of (if any) ellipsization should be applied to a line of text. In the ellipsization process characters are removed from the text in order to make it fit to a given width and replaced with an ellipsis.

ELLIPSIZE_NONE
No ellipsization
ELLIPSIZE_START
Omit characters at the start of the text
ELLIPSIZE_MIDDLE
Omit characters in the middle of the text
ELLIPSIZE_END
Omit characters at the end of the text
ALIGN_CENTER
ALIGN_LEFT
ALIGN_RIGHT
Alignment

ChangeLog

  • 2005-11-10 Added. - Masao?