pango.Context — stores global information used to control rendering.
class pango.Context( |
A pango.Context
object contains global information used to control the rendering
process. The information accessible using the pango.Context
methods includes:
pango.FontDescriptionpango.LanguageA pango.Context can
be created with the gtk.Widget.create_pango_context()
method. The pango.Context
associated with a gtk.Widget is
retrieved using the gtk.Widget.get_pango_context())
method.
pango.Context()Returns : | a new pango.Context
without an associated font map |
Constructor is available in PyGTK 2.16 and above.
Creates a new PangoContext initialized to default values.
This constructor is not particularly useful as it should always be followed by a call to set_font_map method. Method pango.FontMap.create_context does these two steps together and hence users are recommended to use that.
If you are using Pango as part of a higher-level system, that system may have it's own way of create a pango.Context. For instance, the GTK+ toolkit has, among others, gtk.gdk.pango_context_get_for_screen and gtk.Widget.get_pango_context. Use those instead.
def set_font_map(font_map)
| the pango.FontMap
to set object |
This method is available in PyGTK 2.16 and above.
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.
def list_families()Returns : | a tuple containing a set of pango.FontFamily
objects. |
The list_families() method returns a
tuple containing the list of all the pango.FontFamily
objects for a context.
def load_font(desc)
| a pango.FontDescription
describing the font to load |
Returns : | the pango.Font loaded,
or None if no font matched. |
The load_font() method loads and
returns the pango.Font from one
of the fontmaps in the context that is the closest match for the pango.FontDescription
specified by desc.
def load_fontset(desc, language)
| a pango.FontDescription
describing the fonts to load |
| a pango.Language
the fonts will be used for |
Returns : | the pango.FontSet, or
None if no font matched. |
The load_fontset() method loads and
returns a set of fonts (in a pango.FontSet)
from the context that can be used to render a font matching the pango.FontDescription
specified by desc with the pango.Language
specified by language.
def get_metrics(desc, language)
| a pango.FontDescription
object |
| the pango.Language
that determines the script to get the metrics for, or
None to get the metrics for the entire
font. |
Returns : | a pango.FontMetrics
object. |
The get_metrics() method returns the
overall metric information for the font described by the pango.FontDescription
specified by desc. Since the metrics may be
substantially different for different scripts, a pango.Language
(specified by language) can be provided to indicate
that the metrics should correspond to the script(s) used by that language.
If the value of language is None,
the returned pango.FontMetrics
covers the entire font.
The family name in the pango.FontDescription
may be a comma separated list of families. 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.
def set_font_description(desc)
| a pango.FontDescription
object |
The set_font_description() method sets
the default pango.FontDescription
(specified by desc) for the context.
def get_font_description()Returns : | the default font description of the context. |
The get_font_description() method
returns the default pango.FontDescription
for the context.
def get_language()Returns : | the global pango.Language. |
The get_language() method returns the
global pango.Language
for the context.
def set_language(language)
| a pango.Language. |
The set_language() method sets the
global pango.Language
for the context to the value specified by
language.
def set_base_dir(direction)
| the new base direction |
The set_base_dir() method sets the base
text direction for the context to the value specified by
direction. The value of
direction must be one of:
| The text is written left-to-right |
| The text is written right-to-left |
| The text is written vertically top-to-bottom, with the rows ordered from left to right. |
| The text is written vertically top-to-bottom, with the rows ordered from right to left. |
def get_base_dir()Returns : | the base direction for the context. |
The get_base_dir() method returns the
base text direction for the context. See the set_base_dir()
method for more information.