Class Font
- All Implemented Interfaces:
Proxy
- Direct Known Subclasses:
Font.FontImpl
,Font.FontImpl
PangoFont
is used to represent a font in a
rendering-system-independent manner.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Font.Builder<B extends Font.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static class
static class
The FontImpl type represents a native instance of the abstract Font class.Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
-
Constructor Summary
ConstructorDescriptionFont
(MemorySegment address) Create a Font proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected Font
asParent()
Returns this instance as if it were its parent type.static Font.Builder
<? extends Font.Builder> builder()
AFont.Builder
object constructs aFont
with the specified properties.protected Font
describe()
Returns a description of the font, with font size set in points.protected FontDescription
Returns a description of the font, with absolute font size set in device units.static void
descriptionsFree
(@Nullable FontDescription[] descs) Frees an array of font descriptions.static Font
deserialize
(Context context, Bytes bytes) Loads data previously created viaserialize()
.getCoverage
(Language language) Computes the coverage map for a given font and language tag.getFace()
Gets thePangoFontFace
to which this Font belongs.Gets the font map for which the font was created.void
getGlyphExtents
(Glyph glyph, @Nullable Rectangle inkRect, @Nullable Rectangle logicalRect) Gets the logical and ink extents of a glyph within a font.Get ahb_font_t
object backing this font.static MemoryLayout
The memory layout of the native struct.getMetrics
(@Nullable Language language) Gets overall metric information for a font.static Type
getType()
Get the GType of the Font classboolean
hasChar
(int wc) Returns whether the font provides a glyph for this character.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, 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, 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, withProperties
Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getPrivate, readGClass, writeGClass
Methods inherited from class io.github.jwharm.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
-
-
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 Javasuper
keyword, 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
Frees 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
bytes
to the result of serializing the font again.- Parameters:
context
- aPangoContext
bytes
- the bytes containing the data- Returns:
- a new
PangoFont
- Throws:
GErrorException
- seeGError
-
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
PangoFontDescription
object.
-
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
PangoFontDescription
object.
-
getCoverage
-
getFace
Gets thePangoFontFace
to which this Font belongs.- Returns:
- the
PangoFontFace
-
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
PangoContext
holds a reference to the font map.- Returns:
- the
PangoFontMap
for the font
-
getGlyphExtents
public void getGlyphExtents(Glyph glyph, @Nullable @Nullable Rectangle inkRect, @Nullable @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_t
object 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_t
object backing the font
-
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, ornull
to indicate to get the metrics for the entire font.- Returns:
- a
PangoFontMetrics
object. 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:
TRUE
if this Font can renderwc
-
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, org.gnome.glib.Bytes)
.- Returns:
- a
GBytes
containing the serialized form of this Font
-
createHbFont
-
describeAbsolute
-
builder
AFont.Builder
object constructs aFont
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withFont.Builder.build()
.
-