class Pango::Context


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

The information stored by Pango::Context includes the fontmap used to look up fonts, and default values such as the default language, default gravity, or default font.

To obtain a Pango::Context, use Pango::FontMap#create_context.

Defined in:



Class Method Summary

Instance Method Summary

Instance methods inherited from class GObject::Object

==(other : self) ==, bind_property(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags) : GObject::Binding bind_property, bind_property_full(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags, transform_to : GObject::Closure, transform_from : GObject::Closure) : GObject::Binding bind_property_full, data(key : String) : Pointer(Void) | Nil data, finalize finalize, freeze_notify : Nil freeze_notify, getv(names : Enumerable(String), values : Enumerable(_)) : Nil getv, hash(hasher) hash, notify(property_name : String) : Nil notify, notify_by_pspec(pspec : GObject::ParamSpec) : Nil notify_by_pspec, notify_signal notify_signal, property(property_name : String, value : _) : Nil property, qdata(quark : UInt32) : Pointer(Void) | Nil qdata, ref_count : UInt32 ref_count, run_dispose : Nil run_dispose, set_data(key : String, data : Pointer(Void) | Nil) : Nil set_data, set_property(property_name : String, value : _) : Nil set_property, steal_data(key : String) : Pointer(Void) | Nil steal_data, steal_qdata(quark : UInt32) : Pointer(Void) | Nil steal_qdata, thaw_notify : Nil thaw_notify, to_unsafe : Pointer(Void) to_unsafe, watch_closure(closure : GObject::Closure) : Nil watch_closure

Constructor methods inherited from class GObject::Object

cast(obj : GObject::Object) : self cast, new(pointer : Pointer(Void), transfer : GICrystal::Transfer)
, newv(object_type : UInt64, parameters : Enumerable(GObject::Parameter)) : self newv

Class methods inherited from class GObject::Object

cast?(obj : GObject::Object) : self | Nil cast?, compat_control(what : UInt64, data : Pointer(Void) | Nil) : UInt64 compat_control, g_type : UInt64 g_type, interface_find_property(g_iface : GObject::TypeInterface, property_name : String) : GObject::ParamSpec interface_find_property, interface_list_properties(g_iface : GObject::TypeInterface) : Enumerable(GObject::ParamSpec) interface_list_properties

Macros inherited from class GObject::Object

previous_vfunc(*args) previous_vfunc, previous_vfunc!(*args) previous_vfunc!, signal(signature) signal

Constructor Detail

def : self #

Creates a new Pango::Context initialized to default values.

This function is not particularly useful as it should always be followed by a Pango::Context#font_map= call, and the function 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_widget_get_pango_context(). Use those instead.

[View source]

Class Method Detail

def self.g_type : UInt64 #

Returns the type id (GType) registered in GLib type system.

[View source]

Instance Method Detail

def ==(other : self) #
Description copied from class Reference

Returns true if this reference is the same as other. Invokes same?.

def base_dir : Pango::Direction #

Retrieves the base direction for the context.

See Pango::Context#base_dir=.

[View source]
def base_dir=(direction : Pango::Direction) : Nil #

Sets the base direction for the context.

The base direction is used in applying the Unicode bidirectional algorithm; if the direction is %PANGO_DIRECTION_LTR or %PANGO_DIRECTION_RTL, then the value will be used as the paragraph direction in the Unicode bidirectional algorithm. A value of %PANGO_DIRECTION_WEAK_LTR or %PANGO_DIRECTION_WEAK_RTL is used only for paragraphs that do not contain any strong characters themselves.

[View source]
def base_gravity : Pango::Gravity #

Retrieves the base gravity for the context.

See Pango::Context#base_gravity=.

[View source]
def base_gravity=(gravity : Pango::Gravity) : Nil #

Sets the base gravity for the context.

The base gravity is used in laying vertical text out.

[View source]
def changed : Nil #

Forces a change in the context, which will cause any Pango::Layout using this context to re-layout.

This function is only useful when implementing a new backend for Pango, something applications won't do. Backends should call this function if they have attached extra data to the context and such data is changed.

[View source]
def font_description : Pango::FontDescription #

Retrieve the default font description for the context.

[View source]
def font_description=(desc : Pango::FontDescription) : Nil #

Set the default font description for the context

[View source]
def font_map : Pango::FontMap #

Gets the Pango::FontMap used to look up fonts for this context.

[View source]
def font_map=(font_map : Pango::FontMap) : Nil #

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.

[View source]
def gravity : Pango::Gravity #

Retrieves the gravity for the context.

This is similar to Pango::Context#base_gravity, except for when the base gravity is %PANGO_GRAVITY_AUTO for which Pango::Gravity#for_matrix is used to return the gravity from the current context matrix.

[View source]
def gravity_hint : Pango::GravityHint #

Retrieves the gravity hint for the context.

See Pango::Context#gravity_hint= for details.

[View source]
def gravity_hint=(hint : Pango::GravityHint) : Nil #

Sets the gravity hint for the context.

The gravity hint is used in laying vertical text out, and is only relevant if gravity of the context as returned by Pango::Context#gravity is set to %PANGO_GRAVITY_EAST or %PANGO_GRAVITY_WEST.

[View source]
def hash(hasher) #
Description copied from class Reference

See Object#hash(hasher)

def language : Pango::Language #

Retrieves the global language tag for the context.

[View source]
def language=(language : Pango::Language) : Nil #

Sets the global language tag for the context.

The default language for the locale of the running process can be found using Pango::Language#default.

[View source]
def list_families(families : Enumerable(Pango::FontFamily)) : Nil #

List all families for a context.

[View source]
def list_families(*families : Pango::FontFamily) #

[View source]
def load_font(desc : Pango::FontDescription) : Pango::Font | Nil #

Loads the font in one of the fontmaps in the context that is the closest match for desc.

[View source]
def load_fontset(desc : Pango::FontDescription, language : Pango::Language) : Pango::Fontset | Nil #

Load a set of fonts in the context that can be used to render a font matching desc.

[View source]
def matrix : Pango::Matrix | Nil #

Gets the transformation matrix that will be applied when rendering with this context.

See Pango::Context#matrix=.

[View source]
def matrix=(matrix : Pango::Matrix | Nil) : Nil #

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

[View source]
def metrics(desc : Pango::FontDescription | Nil, language : Pango::Language | Nil) : Pango::FontMetrics #

Get overall metric information for a 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 #itemize, and the family name may be a comma separated list of names. 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.

[View source]
def round_glyph_positions : Bool #

Returns whether font rendering with this context should round glyph positions and widths.

[View source]
def round_glyph_positions=(round_positions : Bool) : Nil #

Sets whether font rendering with this context should round glyph positions and widths to integral positions, in device units.

This is useful when the renderer can't handle subpixel positioning of glyphs.

The default value is to round glyph positions, to remain compatible with previous Pango behavior.

[View source]
def serial : UInt32 #

Returns the current serial number of context.

The serial number is initialized to an small number larger than zero when a new context is created and is increased whenever the context is changed using any of the setter functions, or the Pango::FontMap it uses to find fonts has changed. The serial may wrap, but will never have the value 0. Since it can wrap, never compare it with "less than", always use "not equals".

This can be used to automatically detect changes to a Pango::Context, and is only useful when implementing objects that need update when their Pango::Context changes, like Pango::Layout.

[View source]