Crea  Modifica  FrontPage  Indici  Cerca  Ultime modifiche  History  RSS  Login

Pango::Context

class Pango::Context

The Pango::Context object stores global information used to control the itemization process.

Class Methods

Pango::Context.new
Creates a new Pango::Context initialized to default value. This method is only useful when implementing a new backend for Pango, something applications won't do. If you are using Pango as part of a higher-level system, that system may have it's own ways of create a Pango::Context. For instance, the GTK+ toolkit has, among others, Gdk::Pango.context, and Gtk::Widget#pango_context.

Instance Methods

itemize(text, start_index, length, attrs, cached_iter = nil)
Breaks a piece of text into segments with consistent directional level and shaping engine. Each byte of text will be contained in exactly one of the items in the returned list; the generated list of items will be in logical order (the start offsets of the items are ascending). cached_iter should be an iterator over attrs currently positioned at a range before or containing start_index; cached_iter will be advanced to the range covering the position just after start_index + length. (i.e. if itemizing in a loop, just keep passing in the same cached_iter).
  • text: the text(String) to itemize.
  • start_index: first byte in text to process
  • length: the number of bytes (not characters) to process after start_index. This must be >= 0.
  • attrs: the set of attributes that apply to text. (Pango::AttrList?)
  • cached_iter : Cached attribute iterator, or nil
  • Returns: an Array of Pango::Item?.
font_map
Gets the Pango::Fontmap? used to look up fonts for this context. Sinece 1.6
  • Returns : the font map for the Pango::Context. This value is owned by Pango and should not be unreferenced.
font_map=(font_map)
Sets the font map to be searched when fonts are looked-up in this context. This is only for internal use by Pango backends, a Pango::Context obtained via one of the recommended methods should already have a suitable font map.
set_font_map(font_map)
Same as Pango::FontDescription#font_map=.
font_description
Retrieve the default font description for the context.
font_description=(desc)
Set the default font description for the context
  • desc: the new pango font description
  • Returns: desc
set_font_description(desc)
Same as Pango::Context#font_description=.
  • desc: the new pango font description
  • Returns: self
language
Retrieves the global language tag for the context.
  • Returns: the global language tag (Pango::Language?).
language=(language)
Sets the global language tag for the context.
  • language: the new language tag (Pango::Language?).
  • Returns: language
set_language(language)
Same as Pango::Context#language=.
  • language: the new language tag (Pango::Language?).
  • Returns: self
base_dir
Retrieves the base direction for the context. See Pango::Context#base_dir=.
base_dir=(direction)
Sets the base direction for the context. The base direction is used in applying the Unicode bidirectional algorithm; if the direction is Pango::Context::DIRECTION_LTR or Pango::Context::DIRECTION_RTL, then the value will be used as the paragraph direction in the Unicode bidirectional algorithm. A value of Pango::Context::DIRECTION_WEAK_LTR or Pango::Context::DIRECTION_WEAK_RTL is used only for paragraphs that do not contain any strong characters themselves.
set_base_dir(direction)
Same as Pango::Context#base_dir=.
matrix
Gets the transformation matrix that will be applied when rendering with this context. See Pango::Context#matrix=. Since 1.6
  • Returns: the matrix, or nil if no matrix has been set (which is the same as the identity matrix).
matrix=(matrix)
Sets the transformation matrix that will be applied when rendering with this context. Note that reported metrics are in the user space coordinates before the application of the matrix, not device-space coordiantes after the application of the matrix. So, they don't scale with the matrix, though they may change slightly for different matrices, depending on how the text is fit to the pixel grid. Since 1.6
  • matrix: a Pango::Matrix?, or nil to unset any existing matrix. (No matrix set is the same as setting the identity matrix.)
  • Returns: matrix
set_matrix(matrix)
Same as Pango::Context#matrix=. Since 1.6
  • matrix: a Pango::Matrix?, or nil to unset any existing matrix. (No matrix set is the same as setting the identity matrix.)
  • Returns: self
load_font(desc)
Loads the font in one of the fontmaps in the context that is the closest match for desc.
load_fontset(desc, language)
Load a set of fonts in the context that can be used to render a font matching desc.
get_metrics(desc, language = nil)
Get overall metric information for a font particular font description. Since the metrics may be substantially different for different scripts, a language tag can be provided to indicate that the metrics should be retrieved that correspond to the script(s) used by that language. The Pango::FontDescription is interpreted in the same way as by Pango::Context#itemize, and the family name may be a comma separated list of figures. If characters from multiple of these families would be used to render the string, then the returned fonts would be a composite of the metrics for the fonts loaded for the individual families.
  • desc: a Pango::FontDescription
  • language: language tag used to determine which script to get the metrics for. nil means that the language tag from the context will be used. If no language tag is set on the ccontext, metrics large enough to cover a range of languages will be returned. The process of determining such metrics is slow, so it is best to always make sure some real language tag will be used.
  • Returns: a Pango::FontMetrics object.
families
List all families for a context.
list_families
Deprecated Same as Pango::Context#families.
resolution
Gets the resolution for the context. See Pango::Context#resolution=.
  • Returns: the resolution in "dots per inch". A negative value will be returned if no resolution has previously been set. Since 1.10
resolution=(dpi)
Sets the resolution for the context. This is a scale factor between points specified in a Pango::FontDescription and Cairo units. The default value is 96, meaning that a 10 point font will be 13 units high. (10 * 96. / 72. = 13.3).
  • dpi: a Float value of the resolution in "dots per inch". (Physical inches aren't actually involved; the terminology is conventional.) A 0 or negative value means to use the resolution from the font map. Since 1.10
  • Returns: dpi (Float)
set_resolution(dpi)
Same as Pango::Context#resolution=.
  • dpi: a Float value of the resolution in "dots per inch". (Physical inches aren't actually involved; the terminology is conventional.) A 0 or negative value means to use the resolution from the font map. Since 1.10
  • Returns: self
font_options
Gets the Cairo::FontOptions. See Pango::Context#font_options=. Since 1.10
  • Returns: the Cairo::FontOptions
font_options=(options)
Sets the Cairo::FontOptions used when rendering text with this context. These options override any options that Cairo::Context#update_context derives from the target surface. Since 1.10
  • options: a Caifo::FontOptions, or nil to unset any previously set options.
  • Returns: options
set_font_options(options)
Sets the Cairo::FontOptions. Since 1.10
  • options: a Caifo::FontOptions, or nil to unset any previously set options. * Returns: self
colormap=(colormap)
Deprecated This method used to set the colormap to be used for drawing with context. The colormap is now always derived from the graphics context used for drawing, so calling this method is no longer necessary.
set_colormap
Deprecated Same as Pango::Context#colormap=.
  • Returns: self

Constants

Direction

The Pango::Context::Direction class represents a direction in the Unicode bidirectional algorithm; not every value in this enumeration makes sense for every usage of Pango::Context::Direction; for example, the return value of Pango.unichar_direction and Pango.find_base_dir cannot be Pango::Context::DIRECTION_WEAK_LTR or Pango::Context::DIRECTION_WEAK_RTL, since every character is either neutral or has a strong direction; on the other hand Pango::Context::DIRECTION_NEUTRAL doesn't make sense to pass to Pango.log2vis_get_embedding_levels.

The Pango::Context::DIRECTION_TTB_LTR, Pango::Context::DIRECTION_TTB_RTL values come from an earlier interpretation of this enumeration as the writing direction of a block of text and are no longer used; See the Text module of the CSS3 spec for how vertical text is planned to be handled in a future version of Pango. The explanation of why Pango::Context::DIRECTION_TTB_LTR is treated as Pango::Context::DIRECTION_RTL can be found there as well.

Notice: You can omit "Context::" like as Pango::DIRECTION_LTR instead of Pango::Context::DIRECTION_LTR.

DIRECTION_LTR
A strong left-to-right direction
DIRECTION_RTL
A strong right-to-left direction
DIRECTION_TTB_LTR
Deprecated value; treated the same as Pango::DIRECTION_RTL
DIRECTION_TTB_RTL
Deprecated value; treated the same as Pango::DIRECTION_LTR
DIRECTION_WEAK_LTR
A weak left-to-right direction
DIRECTION_WEAK_RTL
A weak right-to-left direction
DIRECTION_NEUTRAL
No direction specified

ChangeLog

  • 2005-11-10 Done for 1.10. - Masao
  • 2005-11-07 Modified. - Masao
  • 2005-11-04 Added. - Masao