- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
UserScaledFontInitFunc
is the type of function which is called when a
scaled-font needs to be created for a user font-face.
The cairo context cr
is not used by the caller, but is prepared in font
space, similar to what the cairo contexts passed to the renderGlyph method will
look like. The callback can use this context for extents computation for example.
After the callback is called, cr
is checked for any error status.
The extents
argument is where the user font sets the font extents for
scaledFont
. It is in font space, which means that for most cases its
ascent and descent members should add to 1.0. extents
is preset to hold a
value of 1.0 for ascent, height, and maxXAdvance, and 0.0 for descent and
maxYAdvance members.
The callback is optional. If not set, default font extents as described in the previous paragraph will be used.
Note that scaledFont
is not fully initialized at this point and trying to
use it for text operations in the callback will result in deadlock.
- Since:
- 1.8
-
Method Summary
Modifier and TypeMethodDescriptionvoid
init
(UserScaledFont scaledFont, Context cr, FontExtents extents) Called when a scaled-font needs to be created for a user font-face.default MemorySegment
toCallback
(Arena arena) Generates an upcall stub, a C function pointer that will callupcall(java.lang.foreign.MemorySegment, java.lang.foreign.MemorySegment, java.lang.foreign.MemorySegment)
.default int
upcall
(MemorySegment scaledFont, MemorySegment cr, MemorySegment extents) The callback that is executed by native code.
-
Method Details
-
init
Called when a scaled-font needs to be created for a user font-face.- Parameters:
scaledFont
- the scaled-font being createdcr
- a cairo context, in font spaceextents
- font extents to fill in, in font space- Throws:
Exception
- when an error occurs. Throwing an exception will trigger aStatus.USER_FONT_ERROR
return value to native code.- Since:
- 1.8
-
upcall
The callback that is executed by native code. This method marshals the parameters and callsinit(org.freedesktop.cairo.UserScaledFont, org.freedesktop.cairo.Context, org.freedesktop.cairo.FontExtents)
.- Parameters:
scaledFont
- the scaled-font being createdcr
- a cairo context, in font spaceextents
- font extents to fill in, in font space- Returns:
Status.SUCCESS
upon success, orStatus.USER_FONT_ERROR
if an exception was thrown.- Since:
- 1.8
-
toCallback
Generates an upcall stub, a C function pointer that will callupcall(java.lang.foreign.MemorySegment, java.lang.foreign.MemorySegment, java.lang.foreign.MemorySegment)
.- Parameters:
arena
- the arena in which the upcall stub will be allocated- Returns:
- the function pointer of the upcall stub
- Since:
- 1.8
-