Package ch.bailu.gtk.pango
Class Context
java.lang.Object
ch.bailu.gtk.type.Type
ch.bailu.gtk.type.Pointer
ch.bailu.gtk.gobject.Object
ch.bailu.gtk.pango.Context
- All Implemented Interfaces:
PointerInterface
A `PangoContext` stores global information used to control the
itemization process.
The information stored by `PangoContext` includes the fontmap used
to look up fonts, and default values such as the default language,
default gravity, or default font.
To obtain a `PangoContext`, use [method@Pango.FontMap.create_context].
itemization process.
The information stored by `PangoContext` includes the fontmap used
to look up fonts, and default values such as the default language,
default gravity, or default font.
To obtain a `PangoContext`, use [method@Pango.FontMap.create_context].
-
Nested Class Summary
Nested classes/interfaces inherited from class ch.bailu.gtk.gobject.Object
Object.OnBindingTransformFunc, Object.OnDestroyNotify, Object.OnDuplicateFunc, Object.OnNotify, Object.OnToggleNotify, Object.OnWeakNotify
-
Field Summary
Fields inherited from class ch.bailu.gtk.gobject.Object
SIGNAL_ON_NOTIFY
-
Constructor Summary
ConstructorDescriptionContext()
Creates a new `PangoContext` initialized to default values.Context
(PointerContainer pointer) -
Method Summary
Modifier and TypeMethodDescriptionvoid
changed()
Forces a change in the context, which will cause any `PangoLayout`
using this context to re-layout.int
Retrieves the base direction for the context.int
Retrieves the base gravity for the context.static ClassHandler
Retrieve the default font description for the context.Gets the `PangoFontMap` used to look up fonts for this context.int
Retrieves the gravity for the context.int
Retrieves the gravity hint for the context.static int
Retrieves the global language tag for the context.Gets the transformation matrix that will be applied when
rendering with this context.getMetrics
(FontDescription desc, Language language) Get overall metric information for a particular font description.static long
static TypeSystem.TypeSize
boolean
Returns whether font rendering with this context should
round glyph positions and widths.int
Returns the current serial number of @context.static long
static TypeSystem.TypeSize
loadFont
(FontDescription desc) Loads the font in one of the fontmaps in the context
that is the closest match for @desc.loadFontset
(FontDescription desc, Language language) Load a set of fonts in the context that can be used to render
a font matching @desc.void
setBaseDir
(int direction) Sets the base direction for the context.void
setBaseGravity
(int gravity) Sets the base gravity for the context.void
Set the default font description for the contextvoid
setFontMap
(FontMap font_map) Sets the font map to be searched when fonts are looked-up
in this context.void
setGravityHint
(int hint) Sets the gravity hint for the context.void
setLanguage
(Language language) Sets the global language tag for the context.void
Sets the transformation matrix that will be applied when rendering
with this context.void
setRoundGlyphPositions
(boolean round_positions) Sets whether font rendering with this context should
round glyph positions and widths to integral positions,
in device units.Methods inherited from class ch.bailu.gtk.gobject.Object
addToggleRef, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, disconnect, disconnect, dupData, dupData, dupQdata, forceFloating, freezeNotify, get, get, getData, getData, getProperty, getProperty, getQdata, interfaceFindProperty, interfaceInstallProperty, isFloating, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, replaceData, replaceData, replaceQdata, runDispose, set, set, setData, setData, setDataFull, setDataFull, setProperty, setProperty, setQdata, setQdataFull, stealData, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref
Methods inherited from class ch.bailu.gtk.type.Pointer
asCPointer, cast, connectSignal, disconnectSignals, disconnectSignals, equals, hashCode, throwIfNull, throwNullPointerException, toString, unregisterCallbacks, unregisterCallbacks
Methods inherited from class ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNull
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface ch.bailu.gtk.type.PointerInterface
asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
-
Constructor Details
-
Context
-
Context
public Context()Creates a new `PangoContext` initialized to default values.
This function is not particularly useful as it should always
be followed by a [method@Pango.Context.set_font_map] call, and the
function [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 `PangoContext`.
For instance, the GTK toolkit has, among others,
`gtk_widget_get_pango_context()`. Use those instead.
-
-
Method Details
-
getClassHandler
-
changed
public void changed()Forces a change in the context, which will cause any `PangoLayout`
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. -
getBaseDir
public int getBaseDir()Retrieves the base direction for the context.
See [method@Pango.Context.set_base_dir].- Returns:
- the base direction for the context.
-
getBaseGravity
public int getBaseGravity()Retrieves the base gravity for the context.
See [method@Pango.Context.set_base_gravity].- Returns:
- the base gravity for the context.
-
getFontDescription
Retrieve the default font description for the context.- Returns:
- a pointer to the context's default font description. This value must not be modified or freed.
-
getFontMap
Gets the `PangoFontMap` used to look up fonts for this context.- Returns:
- the font map for the. `PangoContext` This value is owned by Pango and should not be unreferenced.
-
getGravity
public int getGravity()Retrieves the gravity for the context.
This is similar to [method@Pango.Context.get_base_gravity],
except for when the base gravity is %PANGO_GRAVITY_AUTO for
which [func@Pango.Gravity.get_for_matrix] is used to return the
gravity from the current context matrix.- Returns:
- the resolved gravity for the context.
-
getGravityHint
public int getGravityHint()Retrieves the gravity hint for the context.
See [method@Pango.Context.set_gravity_hint] for details.- Returns:
- the gravity hint for the context.
-
getLanguage
Retrieves the global language tag for the context.- Returns:
- the global language tag.
-
getMatrix
Gets the transformation matrix that will be applied when
rendering with this context.
See [method@Pango.Context.set_matrix].- Returns:
- the matrix, or %NULL if no matrix has been set (which is the same as the identity matrix). The returned matrix is owned by Pango and must not be modified or freed.
-
getMetrics
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 `PangoFontDescription` is interpreted in the same way as by [func@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.- Parameters:
desc
- a `PangoFontDescription` structure. %NULL means that the font description from the context will be used.language
- language tag used to determine which script to get the metrics for. %NULL means that the language tag from the context will be used. If no language tag is set on the context, metrics for the default language (as determined by [func@Pango.Language.get_default] will be returned.- Returns:
- a `PangoFontMetrics` object. The caller must call [method@Pango.FontMetrics.unref] when finished using the object.
-
getRoundGlyphPositions
public boolean getRoundGlyphPositions()Returns whether font rendering with this context should
round glyph positions and widths.- Returns:
-
getSerial
public int getSerial()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 `PangoFontMap` 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 `PangoContext`,
and is only useful when implementing objects that need update when their
`PangoContext` changes, like `PangoLayout`.- Returns:
- The current serial number of @context.
-
loadFont
Loads the font in one of the fontmaps in the context
that is the closest match for @desc.- Parameters:
desc
- a `PangoFontDescription` describing the font to load- Returns:
- the newly allocated `PangoFont` that was loaded, or %NULL if no font matched.
-
loadFontset
Load a set of fonts in the context that can be used to render
a font matching @desc.- Parameters:
desc
- a `PangoFontDescription` describing the fonts to loadlanguage
- a `PangoLanguage` the fonts will be used for- Returns:
- the newly allocated `PangoFontset` loaded, or %NULL if no font matched.
-
setBaseDir
public void setBaseDir(int direction) 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.- Parameters:
direction
- the new base direction
-
setBaseGravity
public void setBaseGravity(int gravity) Sets the base gravity for the context.
The base gravity is used in laying vertical text out.- Parameters:
gravity
- the new base gravity
-
setFontDescription
Set the default font description for the context- Parameters:
desc
- the new pango font description
-
setFontMap
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 `PangoContext`
obtained via one of the recommended methods should already have a
suitable font map.- Parameters:
font_map
- the `PangoFontMap` to set.
-
setGravityHint
public void setGravityHint(int hint) 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
[method@Pango.Context.get_gravity] is set to %PANGO_GRAVITY_EAST
or %PANGO_GRAVITY_WEST.- Parameters:
hint
- the new gravity hint
-
setLanguage
Sets the global language tag for the context.
The default language for the locale of the running process
can be found using [func@Pango.Language.get_default].- Parameters:
language
- the new language tag.
-
setMatrix
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.- Parameters:
matrix
- a `PangoMatrix`, or %NULL to unset any existing matrix. (No matrix set is the same as setting the identity matrix.)
-
setRoundGlyphPositions
public void setRoundGlyphPositions(boolean round_positions) 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.- Parameters:
round_positions
- whether to round glyph positions
-
getTypeID
public static long getTypeID() -
getParentTypeID
public static long getParentTypeID() -
getTypeSize
-
getParentTypeSize
-
getInstanceSize
public static int getInstanceSize()
-