Class Font
- All Implemented Interfaces:
Proxy
- Direct Known Subclasses:
Font.Font$Impl,Font.Font$Impl
PangoFont is used to represent a font in a
rendering-system-independent manner.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classFont.Builder<B extends Font.Builder<B>>Inner class implementing a builder pattern to construct a GObject with properties.static classThe Font$Impl type represents a native instance of the abstract Font class.static classNested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass -
Constructor Summary
ConstructorsConstructorDescriptionFont()Creates a new Font.Font(MemorySegment address) Create a Font proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected FontasParent()Returns this instance as if it were its parent type.protected Fontdescribe()Returns a description of the font, with font size set in points.protected FontDescriptionReturns a description of the font, with absolute font size set in device units.static voiddescriptionsFree(@Nullable FontDescription @Nullable [] descs) Deprecated.Just use pango_font_description_free in a loopstatic @Nullable Fontdeserialize(Context context, byte[] bytes) Loads data previously created viaserialize().getCoverage(Language language) Computes the coverage map for a given font and language tag.@Nullable FontFacegetFace()Gets thePangoFontFaceto which this Font belongs.@Nullable FontMapGets the font map for which the font was created.voidgetGlyphExtents(Glyph glyph, @Nullable Rectangle inkRect, @Nullable Rectangle logicalRect) Gets the logical and ink extents of a glyph within a font.@Nullable FontGet ahb_font_tobject backing this font.static MemoryLayoutThe memory layout of the native struct.getMetrics(@Nullable Language language) Gets overall metric information for a font.static @Nullable TypegetType()Get the GType of the Font classbooleanhasChar(int wc) Returns whether the font provides a glyph for this character.byte[]Serializes the this Font in a way that can be uniquely identified.Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, builder, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, 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
-
Font
Create a Font proxy instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
Font
public Font()Creates a new Font.
-
-
Method Details
-
getType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
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. -
descriptionsFree
Deprecated.Just use pango_font_description_free in a loopFrees an array of font descriptions.- Parameters:
descs- a pointer to an array ofPangoFontDescription, may benull
-
deserialize
Loads data previously created viaserialize().For a discussion of the supported format, see that function.
Note: to verify that the returned font is identical to the one that was serialized, you can compare
bytesto the result of serializing the font again.- Parameters:
context- aPangoContextbytes- the bytes containing the data- Returns:
- a new
PangoFont - Throws:
GErrorException- seeGError- Since:
- 1.50
-
describe
Returns a description of the font, with font size set in points.Use
describeWithAbsoluteSize()if you want the font size in device units.- Returns:
- a newly-allocated
PangoFontDescriptionobject.
-
describeWithAbsoluteSize
Returns a description of the font, with absolute font size set in device units.Use
describe()if you want the font size in points.- Returns:
- a newly-allocated
PangoFontDescriptionobject. - Since:
- 1.14
-
getCoverage
-
getFace
Gets thePangoFontFaceto which this Font belongs.Note that this function can return
NULLin cases where the font outlives its font map.- Returns:
- the
PangoFontFace - Since:
- 1.46
-
getFontMap
Gets the font map for which the font was created.Note that the font maintains a weak reference to the font map, so if all references to font map are dropped, the font map will be finalized even if there are fonts created with the font map that are still alive. In that case this function will return
null.It is the responsibility of the user to ensure that the font map is kept alive. In most uses this is not an issue as a
PangoContextholds a reference to the font map.- Returns:
- the
PangoFontMapfor the font - Since:
- 1.10
-
getGlyphExtents
public void getGlyphExtents(Glyph glyph, @Nullable Rectangle inkRect, @Nullable Rectangle logicalRect) Gets the logical and ink extents of a glyph within a font.The coordinate system for each rectangle has its origin at the base line and horizontal origin of the character with increasing coordinates extending to the right and down. The macros PANGO_ASCENT(), PANGO_DESCENT(), PANGO_LBEARING(), and PANGO_RBEARING() can be used to convert from the extents rectangle to more traditional font metrics. The units of the rectangles are in 1/PANGO_SCALE of a device unit.
If this Font is
null, this function gracefully sets some sane values in the output variables and returns.- Parameters:
glyph- the glyph indexinkRect- rectangle used to store the extents of the glyph as drawnlogicalRect- rectangle used to store the logical extents of the glyph
-
getHbFont
Get ahb_font_tobject backing this font.Note that the objects returned by this function are cached and immutable. If you need to make changes to the
hb_font_t, use hb_font_create_sub_font().- Returns:
- the
hb_font_tobject backing the font - Since:
- 1.44
-
getMetrics
Gets overall metric information for a font.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.
If this Font is
null, this function gracefully sets some sane values in the output variables and returns.- Parameters:
language- language tag used to determine which script to get the metrics for, ornullto indicate to get the metrics for the entire font.- Returns:
- a
PangoFontMetricsobject. The caller must callFontMetrics.unref()when finished using the object.
-
hasChar
public boolean hasChar(int wc) Returns whether the font provides a glyph for this character.- Parameters:
wc- a Unicode character- Returns:
TRUEif this Font can renderwc- Since:
- 1.44
-
serialize
public byte[] serialize()Serializes the this Font in a way that can be uniquely identified.There are no guarantees about the format of the output across different versions of Pango.
The intended use of this function is testing, benchmarking and debugging. The format is not meant as a permanent storage format.
To recreate a font from its serialized form, use
deserialize(org.gnome.pango.Context, byte[]).- Returns:
- a
GBytescontaining the serialized form of this Font - Since:
- 1.50
-
createHbFont
-
describeAbsolute
-