Class Context
- All Implemented Interfaces:
Proxy
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 FontMap.createContext().
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classContext.Builder<B extends Context.Builder<B>>Inner class implementing a builder pattern to construct a GObject with properties.static classNested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass -
Constructor Summary
ConstructorsConstructorDescriptionContext()Creates a new Context.Context(MemorySegment address) Create a Context proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected ContextasParent()Returns this instance as if it were its parent type.static Context.Builder<? extends Context.Builder> builder()AContext.Builderobject constructs aContextwith the specified properties.voidchanged()Forces a change in the context, which will cause anyPangoLayoutusing this context to re-layout.Retrieves the base direction for the context.Retrieves the base gravity for the context.@Nullable FontDescriptionRetrieve the default font description for the context.@Nullable FontMapGets thePangoFontMapused to look up fonts for this context.Retrieves the gravity for the context.Retrieves the gravity hint for the context.Retrieves the global language tag for the context.@Nullable MatrixGets the transformation matrix that will be applied when rendering with this context.getMetrics(@Nullable FontDescription desc, @Nullable Language language) Get overall metric information for a particular font description.booleanReturns whether font rendering with this context should round glyph positions and widths.intReturns the current serial number ofcontext.static @Nullable TypegetType()Get the GType of the Context classvoidlistFamilies(@Nullable Out<FontFamily[]> families) List all families for a context.@Nullable FontloadFont(FontDescription desc) Loads the font in one of the fontmaps in the context that is the closest match fordesc.@Nullable FontsetloadFontset(FontDescription desc, Language language) Load a set of fonts in the context that can be used to render a font matchingdesc.voidsetBaseDir(Direction direction) Sets the base direction for the context.voidsetBaseGravity(Gravity gravity) Sets the base gravity for the context.voidsetFontDescription(@Nullable FontDescription desc) Set the default font description for the contextvoidsetFontMap(@Nullable FontMap fontMap) Sets the font map to be searched when fonts are looked-up in this context.voidsetGravityHint(GravityHint hint) Sets the gravity hint for the context.voidsetLanguage(@Nullable Language language) Sets the global language tag for the context.voidSets the transformation matrix that will be applied when rendering with this context.voidsetRoundGlyphPositions(boolean roundPositions) Sets whether font rendering with this context should round glyph positions and widths to integral positions, in device units.Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getMemoryLayout, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newv, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withPropertiesMethods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class org.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
Context
Create a Context proxy instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
Context
public Context()Creates a new Context.
-
-
Method Details
-
getType
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuperkeyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName(). This will call the native function pointer of this virtual method in the typeclass of the parent type. -
changed
public void changed()Forces a change in the context, which will cause anyPangoLayoutusing 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.
- Since:
- 1.32.4
-
getBaseDir
Retrieves the base direction for the context.- Returns:
- the base direction for the context.
-
getBaseGravity
Retrieves the base gravity for the context.- Returns:
- the base gravity for the context.
- Since:
- 1.16
-
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 thePangoFontMapused to look up fonts for this context.- Returns:
- the font map for the.
PangoContextThis value is owned by Pango and should not be unreferenced. - Since:
- 1.6
-
getGravity
Retrieves the gravity for the context.This is similar to
getBaseGravity(), except for when the base gravity isGravity.AUTOfor whichGravity.getForMatrix(org.gnome.pango.Matrix)is used to return the gravity from the current context matrix.- Returns:
- the resolved gravity for the context.
- Since:
- 1.16
-
getGravityHint
Retrieves the gravity hint for the context.See
setGravityHint(org.gnome.pango.GravityHint)for details.- Returns:
- the gravity hint for the context.
- Since:
- 1.16
-
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.- Returns:
- the matrix, or
nullif 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. - Since:
- 1.6
-
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
PangoFontDescriptionis interpreted in the same way as byPango.itemize(org.gnome.pango.Context, java.lang.String, int, int, org.gnome.pango.AttrList, org.gnome.pango.AttrIterator), 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- aPangoFontDescriptionstructure.nullmeans that the font description from the context will be used.language- language tag used to determine which script to get the metrics for.nullmeans 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 byLanguage.getDefault()will be returned.- Returns:
- a
PangoFontMetricsobject. The caller must callFontMetrics.unref()when finished using the object.
-
getRoundGlyphPositions
public boolean getRoundGlyphPositions()Returns whether font rendering with this context should round glyph positions and widths.- Since:
- 1.44
-
getSerial
public int getSerial()Returns the current serial number ofcontext.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
PangoFontMapit 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 theirPangoContextchanges, likePangoLayout.- Returns:
- The current serial number of
context. - Since:
- 1.32.4
-
listFamilies
List all families for a context.- Parameters:
families- location to store a pointer to an array ofPangoFontFamily. This array should be freed with g_free().
-
loadFont
Loads the font in one of the fontmaps in the context that is the closest match fordesc.- Parameters:
desc- aPangoFontDescriptiondescribing the font to load- Returns:
- the newly allocated
PangoFontthat was loaded, ornullif no font matched.
-
loadFontset
Load a set of fonts in the context that can be used to render a font matchingdesc.- Parameters:
desc- aPangoFontDescriptiondescribing the fonts to loadlanguage- aPangoLanguagethe fonts will be used for- Returns:
- the newly allocated
PangoFontsetloaded, ornullif no font matched.
-
setBaseDir
Sets the base direction for the context.The base direction is used in applying the Unicode bidirectional algorithm; if the
directionisDirection.LTRorDirection.RTL, then the value will be used as the paragraph direction in the Unicode bidirectional algorithm. A value ofDirection.WEAK_LTRorDirection.WEAK_RTLis used only for paragraphs that do not contain any strong characters themselves.- Parameters:
direction- the new base direction
-
setBaseGravity
Sets the base gravity for the context.The base gravity is used in laying vertical text out.
- Parameters:
gravity- the new base gravity- Since:
- 1.16
-
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
PangoContextobtained via one of the recommended methods should already have a suitable font map.- Parameters:
fontMap- thePangoFontMapto set.
-
setGravityHint
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
getGravity()is set toGravity.EASTorGravity.WEST.- Parameters:
hint- the new gravity hint- Since:
- 1.16
-
setLanguage
Sets the global language tag for the context.The default language for the locale of the running process can be found using
Language.getDefault().- 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- aPangoMatrix, ornullto unset any existing matrix. (No matrix set is the same as setting the identity matrix.)- Since:
- 1.6
-
setRoundGlyphPositions
public void setRoundGlyphPositions(boolean roundPositions) 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:
roundPositions- whether to round glyph positions- Since:
- 1.44
-
builder
AContext.Builderobject constructs aContextwith the specified properties. Use the variousset...()methods to set properties, and finish construction withContext.Builder.build().- Returns:
- the builder object
-