The user-font feature allows the cairo user to provide drawings for glyphs in a font. This is most useful in implementing fonts in non-standard formats, like SVG fonts and Flash fonts, but can also be used by games and other application to draw "funky" fonts.
- Since:
- 1.8
-
Constructor Summary
ConstructorsConstructorDescriptionUserFontFace(MemorySegment address) Constructor used internally to instantiate a java UserFontFace object for a nativecairo_font_faceinstance -
Method Summary
Modifier and TypeMethodDescriptionstatic UserFontFacecreate()Creates a new user font-face.Gets the scaled-font initialization function of a user-font.Gets the color glyph rendering function of a user-font.Gets the glyph rendering function of a user-font.Gets the text-to-glyphs conversion function of a user-font.Gets the unicode-to-glyph conversion function of a user-font.voidsetInitFunc(UserScaledFontInitFunc initFunc) Sets the scaled-font initialization function of a user-font.voidsetRenderColorGlyphFunc(UserScaledFontRenderGlyphFunc renderGlyphFunc) Sets the color glyph rendering function of a user-font.voidsetRenderGlyphFunc(UserScaledFontRenderGlyphFunc renderGlyphFunc) Sets the glyph rendering function of a user-font.voidsetTextToGlyphsFunc(UserScaledFontTextToGlyphsFunc textToGlyphsFunc) Sets th text-to-glyphs conversion function of a user-font.voidsetUnicodeToGlyphFunc(UserScaledFontUnicodeToGlyphFunc unicodeToGlyphFunc) Sets the unicode-to-glyph conversion function of a user-font.Methods inherited from class org.freedesktop.cairo.FontFace
destroy, getFontType, getType, getUserData, setUserData, status
-
Constructor Details
-
UserFontFace
Constructor used internally to instantiate a java UserFontFace object for a nativecairo_font_faceinstance- Parameters:
address- the memory address of the nativecairo_font_faceinstance
-
-
Method Details
-
create
Creates a new user font-face.Use the setter functions to associate callbacks with the returned user font. The only mandatory callback is render_glyph.
After the font-face is created, the user can attach arbitrary data (the actual font data) to it using
FontFace.setUserData(org.freedesktop.cairo.UserDataKey, java.lang.foreign.MemorySegment)and access it from the user-font callbacks by usingScaledFont.getFontFace()followed byFontFace.getUserData(org.freedesktop.cairo.UserDataKey).- Returns:
- a newly created UserFontFace
- Since:
- 1.8
-
setInitFunc
Sets the scaled-font initialization function of a user-font. SeeUserScaledFontInitFuncfor details of how the callback works.The font-face should not be immutable or an
IllegalStateExceptionwill be thrown. A user font-face is immutable as soon as a scaled-font is created from it.- Parameters:
initFunc- The init callback, ornull- Throws:
IllegalStateException- Since:
- 1.8
-
getInitFunc
Gets the scaled-font initialization function of a user-font.- Returns:
- The init callback of this font-face or
nullif none set or an error has occurred. - Since:
- 1.8
-
setRenderGlyphFunc
public void setRenderGlyphFunc(UserScaledFontRenderGlyphFunc renderGlyphFunc) throws IllegalStateException Sets the glyph rendering function of a user-font. SeeUserScaledFontRenderGlyphFuncfor details of how the callback works.The font-face should not be immutable or an
IllegalStateExceptionwill be thrown. A user font-face is immutable as soon as a scaled-font is created from it.The render_glyph callback is the only mandatory callback of a user-font. At least one of
setRenderColorGlyphFunc(org.freedesktop.cairo.UserScaledFontRenderGlyphFunc)orsetRenderGlyphFuncmust be called to set a render callback. If both callbacks are set, the color glyph render callback is invoked first. If the color glyph render callback throwsUnsupportedOperationException, the non-color version of the callback is invoked.If the callback is
nulland a glyph is tried to be rendered using this font-face, anIllegalStateExceptionwill be thrown.- Parameters:
renderGlyphFunc- The render_glyph callback, ornull- Throws:
IllegalStateException- when the font-face is immutable, or the callback is null and a glyph is tried to be rendered using this font-face- Since:
- 1.8
-
getRenderGlyphFunc
Gets the glyph rendering function of a user-font.- Returns:
- The render_glyph callback of this font-face or
nullif none set or an error has occurred. - Since:
- 1.8
-
setRenderColorGlyphFunc
public void setRenderColorGlyphFunc(UserScaledFontRenderGlyphFunc renderGlyphFunc) throws IllegalStateException Sets the color glyph rendering function of a user-font. SeeUserScaledFontRenderGlyphFuncfor details of how the callback works.The font-face should not be immutable or an
IllegalStateExceptionwill be thrown. A user font-face is immutable as soon as a scaled-font is created from it.The render_glyph callback is the only mandatory callback of a user-font. At least one of
setRenderColorGlyphFuncorsetRenderGlyphFunc(org.freedesktop.cairo.UserScaledFontRenderGlyphFunc)must be called to set a render callback. If both callbacks are set, the color glyph render callback is invoked first. If the color glyph render callback throwsUnsupportedOperationException, the non-color version of the callback is invoked.If the callback is
nulland a glyph is tried to be rendered using this font-face, anIllegalStateExceptionwill be thrown.- Parameters:
renderGlyphFunc- The render_glyph callback, ornull- Throws:
IllegalStateException- when the font-face is immutable, or the callback is null and a glyph is tried to be rendered using this font-face- Since:
- 1.8
-
getRenderColorGlyphFunc
Gets the color glyph rendering function of a user-font.- Returns:
- The render_glyph callback of this font-face or
nullif none set or an error has occurred. - Since:
- 1.8
-
setUnicodeToGlyphFunc
public void setUnicodeToGlyphFunc(UserScaledFontUnicodeToGlyphFunc unicodeToGlyphFunc) throws IllegalStateException Sets the unicode-to-glyph conversion function of a user-font. SeeUserScaledFontUnicodeToGlyphFuncfor details of how the callback works.The font-face should not be immutable or an
IllegalStateExceptionwill be thrown. A user font-face is immutable as soon as a scaled-font is created from it.- Parameters:
unicodeToGlyphFunc- The unicode_to_glyph callback, ornull- Throws:
IllegalStateException- when the font-face is immutable- Since:
- 1.8
-
getUnicodeToGlyphFunc
Gets the unicode-to-glyph conversion function of a user-font.- Returns:
- The unicode_to_glyph callback of this font-face or
nullif none set or an error occurred. - Since:
- 1.8
-
setTextToGlyphsFunc
public void setTextToGlyphsFunc(UserScaledFontTextToGlyphsFunc textToGlyphsFunc) throws IllegalStateException Sets th text-to-glyphs conversion function of a user-font. See cairo_user_scaled_font_text_to_glyphs_func_t for details of how the callback works.The font-face should not be immutable or an
IllegalStateExceptionwill be thrown. A user font-face is immutable as soon as a scaled-font is created from it.- Parameters:
textToGlyphsFunc- The text_to_glyphs callback, ornull- Throws:
IllegalStateException- when the font-face is immutable- Since:
- 1.8
-
getTextToGlyphsFunc
Gets the text-to-glyphs conversion function of a user-font.- Returns:
- The text_to_glyphs callback of this font-face or
nullif none set or an error occurred. - Since:
- 1.8
-