Class PangoCairo
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic @Nullable org.freedesktop.cairo.FontOptionscontextGetFontOptions(Context context) Retrieves any font rendering options previously set withcontextSetFontOptions(org.gnome.pango.Context, org.freedesktop.cairo.FontOptions).static doublecontextGetResolution(Context context) Gets the resolution for the context.static @Nullable ShapeRendererFunccontextGetShapeRenderer(Context context, @Nullable MemorySegment data) Sets callback function for context to use for rendering attributes of typeAttrType.SHAPE.static voidcontextSetFontOptions(Context context, @Nullable org.freedesktop.cairo.FontOptions options) Sets the font options used when rendering text with this context.static voidcontextSetResolution(Context context, double dpi) Sets the resolution for the context.static voidcontextSetShapeRenderer(Context context, @Nullable ShapeRendererFunc func) Sets callback function for context to use for rendering attributes of typeAttrType.SHAPE.static ContextcreateContext(org.freedesktop.cairo.Context cr) Creates a context object set up to match the current transformation and target surface of the Cairo context.static LayoutcreateLayout(org.freedesktop.cairo.Context cr) Creates a layout object set up to match the current transformation and target surface of the Cairo context.static voiderrorUnderlinePath(org.freedesktop.cairo.Context cr, double x, double y, double width, double height) Add a squiggly line to the current path in the specified cairo context that approximately covers the given rectangle in the style of an underline used to indicate a spelling error.static voidglyphStringPath(org.freedesktop.cairo.Context cr, Font font, GlyphString glyphs) Adds the glyphs inglyphsto the current path in the specified cairo context.static voidstatic voidlayoutLinePath(org.freedesktop.cairo.Context cr, LayoutLine line) Adds the text inPangoLayoutLineto the current path in the specified cairo context.static voidlayoutPath(org.freedesktop.cairo.Context cr, Layout layout) Adds the text in aPangoLayoutto the current path in the specified cairo context.static voidshowErrorUnderline(org.freedesktop.cairo.Context cr, double x, double y, double width, double height) Draw a squiggly line in the specified cairo context that approximately covers the given rectangle in the style of an underline used to indicate a spelling error.static voidshowGlyphItem(org.freedesktop.cairo.Context cr, String text, GlyphItem glyphItem) Draws the glyphs inglyphItemin the specified cairo context,static voidshowGlyphString(org.freedesktop.cairo.Context cr, Font font, GlyphString glyphs) Draws the glyphs inglyphsin the specified cairo context.static voidshowLayout(org.freedesktop.cairo.Context cr, Layout layout) Draws aPangoLayoutin the specified cairo context.static voidshowLayoutLine(org.freedesktop.cairo.Context cr, LayoutLine line) Draws aPangoLayoutLinein the specified cairo context.static voidupdateContext(org.freedesktop.cairo.Context cr, Context context) Updates aPangoContextpreviously created for use with Cairo to match the current transformation and target surface of a Cairo context.static voidupdateLayout(org.freedesktop.cairo.Context cr, Layout layout) Updates the privatePangoContextof aPangoLayoutcreated withcreateLayout(org.freedesktop.cairo.Context)to match the current transformation and target surface of a Cairo context.
-
Constructor Details
-
PangoCairo
public PangoCairo()
-
-
Method Details
-
javagi$ensureInitialized
public static void javagi$ensureInitialized() -
contextGetFontOptions
Retrieves any font rendering options previously set withcontextSetFontOptions(org.gnome.pango.Context, org.freedesktop.cairo.FontOptions).This function does not report options that are derived from the target surface by
updateContext(org.freedesktop.cairo.Context, org.gnome.pango.Context).- Parameters:
context- aPangoContext, from a pangocairo font map- Returns:
- the font options previously set on the
context, or
nullif no options have been set. This value is owned by the context and must not be modified or freed. - Since:
- 1.10
-
contextGetResolution
Gets the resolution for the context.- Parameters:
context- aPangoContext, from a pangocairo font map- Returns:
- the resolution in "dots per inch". A negative value will be returned if no resolution has previously been set.
- Since:
- 1.10
-
contextGetShapeRenderer
public static @Nullable ShapeRendererFunc contextGetShapeRenderer(Context context, @Nullable MemorySegment data) Sets callback function for context to use for rendering attributes of typeAttrType.SHAPE.See
PangoCairoShapeRendererFuncfor details.Retrieves callback function and associated user data for rendering attributes of type
AttrType.SHAPEas set bycontextSetShapeRenderer(org.gnome.pango.Context, org.gnome.pango.cairo.ShapeRendererFunc), if any.- Parameters:
context- aPangoContext, from a pangocairo font mapdata- Pointer togpointerto return user data- Returns:
- the shape rendering callback
previously set on the context, or
nullif no shape rendering callback have been set. - Since:
- 1.18
-
contextSetFontOptions
public static void contextSetFontOptions(Context context, @Nullable org.freedesktop.cairo.FontOptions options) Sets the font options used when rendering text with this context.These options override any options that
updateContext(org.freedesktop.cairo.Context, org.gnome.pango.Context)derives from the target surface.- Parameters:
context- aPangoContext, from a pangocairo font mapoptions- acairo_font_options_t, ornullto unset any previously set options. A copy is made.- Since:
- 1.10
-
contextSetResolution
Sets the resolution for the context.This is a scale factor between points specified in a
PangoFontDescriptionand Cairo units. The default value is 96, meaning that a 10 point font will be 13 units high. (10 * 96. / 72. = 13.3).- Parameters:
context- aPangoContext, from a pangocairo font mapdpi- the resolution in "dots per inch". (Physical inches aren't actually involved; the terminology is conventional.) A 0 or negative value means to use the resolution from the font map.- Since:
- 1.10
-
contextSetShapeRenderer
Sets callback function for context to use for rendering attributes of typeAttrType.SHAPE.See
PangoCairoShapeRendererFuncfor details.- Parameters:
context- aPangoContext, from a pangocairo font mapfunc- Callback function for rendering attributes of typeAttrType.SHAPE, ornullto disable shape rendering.- Since:
- 1.18
-
createContext
Creates a context object set up to match the current transformation and target surface of the Cairo context.This context can then be used to create a layout using
Layout().This function is a convenience function that creates a context using the default font map, then updates it to
cr.If you just need to create a layout for use withcrand do not need to accessPangoContextdirectly, you can usecreateLayout(org.freedesktop.cairo.Context)instead.- Parameters:
cr- a Cairo context- Returns:
- the newly created
PangoContext - Since:
- 1.22
-
createLayout
Creates a layout object set up to match the current transformation and target surface of the Cairo context.This layout can then be used for text measurement with functions like
Layout.getSize(org.javagi.base.Out<java.lang.Integer>, org.javagi.base.Out<java.lang.Integer>)or drawing with functions likeshowLayout(org.freedesktop.cairo.Context, org.gnome.pango.Layout). If you change the transformation or target surface forcr,you need to callupdateLayout(org.freedesktop.cairo.Context, org.gnome.pango.Layout).This function is the most convenient way to use Cairo with Pango, however it is slightly inefficient since it creates a separate
PangoContextobject for each layout. This might matter in an application that was laying out large amounts of text.- Parameters:
cr- a Cairo context- Returns:
- the newly created
PangoLayout - Since:
- 1.10
-
errorUnderlinePath
public static void errorUnderlinePath(org.freedesktop.cairo.Context cr, double x, double y, double width, double height) Add a squiggly line to the current path in the specified cairo context that approximately covers the given rectangle in the style of an underline used to indicate a spelling error.The width of the underline is rounded to an integer number of up/down segments and the resulting rectangle is centered in the original rectangle.
- Parameters:
cr- a Cairo contextx- The X coordinate of one corner of the rectangley- The Y coordinate of one corner of the rectanglewidth- Non-negative width of the rectangleheight- Non-negative height of the rectangle- Since:
- 1.14
-
glyphStringPath
Adds the glyphs inglyphsto the current path in the specified cairo context.The origin of the glyphs (the left edge of the baseline) will be at the current point of the cairo context.
- Parameters:
cr- a Cairo contextfont- aPangoFontfrom aPangoCairoFontMapglyphs- aPangoGlyphString- Since:
- 1.10
-
layoutLinePath
Adds the text inPangoLayoutLineto the current path in the specified cairo context.The origin of the glyphs (the left edge of the line) will be at the current point of the cairo context.
- Parameters:
cr- a Cairo contextline- aPangoLayoutLine- Since:
- 1.10
-
layoutPath
Adds the text in aPangoLayoutto the current path in the specified cairo context.The top-left corner of the
PangoLayoutwill be at the current point of the cairo context.- Parameters:
cr- a Cairo contextlayout- a Pango layout- Since:
- 1.10
-
showErrorUnderline
public static void showErrorUnderline(org.freedesktop.cairo.Context cr, double x, double y, double width, double height) Draw a squiggly line in the specified cairo context that approximately covers the given rectangle in the style of an underline used to indicate a spelling error.The width of the underline is rounded to an integer number of up/down segments and the resulting rectangle is centered in the original rectangle.
- Parameters:
cr- a Cairo contextx- The X coordinate of one corner of the rectangley- The Y coordinate of one corner of the rectanglewidth- Non-negative width of the rectangleheight- Non-negative height of the rectangle- Since:
- 1.14
-
showGlyphItem
public static void showGlyphItem(org.freedesktop.cairo.Context cr, String text, GlyphItem glyphItem) Draws the glyphs inglyphItemin the specified cairo context,embedding the text associated with the glyphs in the output if the output format supports it (PDF for example), otherwise it acts similar to
showGlyphString(org.freedesktop.cairo.Context, org.gnome.pango.Font, org.gnome.pango.GlyphString).The origin of the glyphs (the left edge of the baseline) will be drawn at the current point of the cairo context.
Note that
textis the start of the text for layout, which is then indexed byglyph_item->item->offset.- Parameters:
cr- a Cairo contexttext- the UTF-8 text thatglyphItemrefers toglyphItem- aPangoGlyphItem- Since:
- 1.22
-
showGlyphString
Draws the glyphs inglyphsin the specified cairo context.The origin of the glyphs (the left edge of the baseline) will be drawn at the current point of the cairo context.
- Parameters:
cr- a Cairo contextfont- aPangoFontfrom aPangoCairoFontMapglyphs- aPangoGlyphString- Since:
- 1.10
-
showLayout
Draws aPangoLayoutin the specified cairo context.The top-left corner of the
PangoLayoutwill be drawn at the current point of the cairo context.- Parameters:
cr- a Cairo contextlayout- a Pango layout- Since:
- 1.10
-
showLayoutLine
Draws aPangoLayoutLinein the specified cairo context.The origin of the glyphs (the left edge of the line) will be drawn at the current point of the cairo context.
- Parameters:
cr- a Cairo contextline- aPangoLayoutLine- Since:
- 1.10
-
updateContext
Updates aPangoContextpreviously created for use with Cairo to match the current transformation and target surface of a Cairo context.If any layouts have been created for the context, it's necessary to call
Layout.contextChanged()on those layouts.- Parameters:
cr- a Cairo contextcontext- aPangoContext, from a pangocairo font map- Since:
- 1.10
-
updateLayout
Updates the privatePangoContextof aPangoLayoutcreated withcreateLayout(org.freedesktop.cairo.Context)to match the current transformation and target surface of a Cairo context.- Parameters:
cr- a Cairo contextlayout- aPangoLayout, fromcreateLayout(org.freedesktop.cairo.Context)- Since:
- 1.10
-