The font options specify how fonts should be rendered. Most of the time the font options implied by a surface are just right and do not need any changes, but for pixel-based targets tweaking font options may result in superior output on a particular display.
Individual features of a cairo_font_options_t can be set or accessed using
functions named FontOptions.setFeatureName()
and
FontOptions.getFeatureName()
, like setAntialias(Antialias)
and getAntialias()
.
New features may be added to FontOptions in the future. For this reason,
copy()
, equals(Object)
, merge(FontOptions)
and
hashCode()
should be used to copy, check for equality, merge, or
compute a hash value of FontOptions objects.
- Since:
- 1.0
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
The default color palette index. -
Constructor Summary
ConstructorDescriptionFontOptions
(MemorySegment address) Constructor used internally to instantiate a java FontOptions object for a nativecairo_font_options_t
instance -
Method Summary
Modifier and TypeMethodDescriptioncopy()
Allocates a new font options object copying the option values from the original.static FontOptions
create()
Allocates a new font options object with all options initialized to default values.void
destroy()
Invokes the cleanup action that is normally invoked during garbage collection.boolean
Compares two font options objects for equality.Gets the antialiasing mode for the font options object.Gets the color mode for the font options object.int
Gets the current OpenType color font palette for the font options object.getCustomPaletteColor
(int index) Gets the custom palette color for the color index for the font options object.Gets the metrics hinting mode for the font options object.Gets the hint style for font outlines for the font options object.Gets the subpixel order for the font options object.static org.gnome.glib.Type
getType()
Get the CairoFontOptions GTypeGets the OpenType font variations for the font options object.int
hashCode()
Compute a hash for the font options object; this value will be useful when storing an object containing FontOptions in a hash table.void
merge
(FontOptions other) Merges non-default options from other into this FontOptions, replacing existing values.void
setAntialias
(Antialias antialias) Sets the antialiasing mode for the font options object.void
setColorMode
(ColorMode colorMode) Sets the color mode for the font options object.void
setColorPalette
(int colorPalette) Sets the OpenType font color palette for the font options object.void
setCustomPaletteColor
(int index, double red, double green, double blue, double alpha) Sets a custom palette color for the font options object.void
setHintMetrics
(HintMetrics hintMetrics) Sets the metrics hinting mode for the font options object.void
setHintStyle
(HintStyle hintStyle) Sets the hint style for font outlines for the font options object.void
setSubpixelOrder
(SubpixelOrder subpixelOrder) Sets the subpixel order for the font options object.void
setVariations
(String variations) Sets the OpenType font variations for the font options object.status()
Checks whether an error has previously occurred for this font options object
-
Field Details
-
COLOR_PALETTE_DEFAULT
public static final int COLOR_PALETTE_DEFAULTThe default color palette index.- Since:
- 1.18
- See Also:
-
-
Constructor Details
-
FontOptions
Constructor used internally to instantiate a java FontOptions object for a nativecairo_font_options_t
instance- Parameters:
address
- the memory address of the nativecairo_font_options_t
instance
-
-
Method Details
-
destroy
public void destroy()Invokes the cleanup action that is normally invoked during garbage collection. If the instance is "owned" by the user, thedestroy()
function is run to dispose the native instance. -
create
Allocates a new font options object with all options initialized to default values.- Returns:
- newly allocated FontOptions
- Since:
- 1.0
-
copy
Allocates a new font options object copying the option values from the original.- Returns:
- newly allocated FontOptions
- Since:
- 1.0
-
status
Checks whether an error has previously occurred for this font options object- Returns:
Status.SUCCESS
,Status.NO_MEMORY
orStatus.NULL_POINTER
.- Since:
- 1.0
-
merge
Merges non-default options from other into this FontOptions, replacing existing values. This operation can be thought of as somewhat similar to compositing other onto options with the operation ofOperator.OVER
.- Parameters:
other
- another FontOptions- Since:
- 1.0
-
hashCode
public int hashCode()Compute a hash for the font options object; this value will be useful when storing an object containing FontOptions in a hash table. -
equals
Compares two font options objects for equality. -
setAntialias
Sets the antialiasing mode for the font options object. This specifies the type of antialiasing to do when rendering text.- Parameters:
antialias
- the new antialiasing mode- Since:
- 1.0
-
getAntialias
Gets the antialiasing mode for the font options object.- Returns:
- the antialiasing mode
- Since:
- 1.0
-
setSubpixelOrder
Sets the subpixel order for the font options object. The subpixel order specifies the order of color elements within each pixel on the display device when rendering with an antialiasing mode ofAntialias.SUBPIXEL
. See the documentation forSubpixelOrder
for full details.- Parameters:
subpixelOrder
- the new subpixel order- Since:
- 1.0
-
getSubpixelOrder
Gets the subpixel order for the font options object. See the documentation forSubpixelOrder
for full details.- Returns:
- the subpixel order for the font options object
- Since:
- 1.0
-
setHintStyle
Sets the hint style for font outlines for the font options object. This controls whether to fit font outlines to the pixel grid, and if so, whether to optimize for fidelity or contrast. See the documentation forHintStyle
for full details.- Parameters:
hintStyle
- the new hint style- Since:
- 1.0
-
getHintStyle
-
setHintMetrics
Sets the metrics hinting mode for the font options object. This controls whether metrics are quantized to integer values in device units. See the documentation forHintMetrics
for full details.- Parameters:
hintMetrics
- the new metrics hinting mode- Since:
- 1.0
-
getHintMetrics
Gets the metrics hinting mode for the font options object. See the documentation forHintMetrics
for full details.- Returns:
- the metrics hinting mode for the font options object
- Since:
- 1.0
-
getVariations
Gets the OpenType font variations for the font options object. SeesetVariations(String)
for details about the string format.- Returns:
- the font variations for the font options object
- Since:
- 1.16
-
setVariations
Sets the OpenType font variations for the font options object. Font variations are specified as a string with a format that is similar to the CSS font-variation-settings. The string contains a comma-separated list of axis assignments, which each assignment consists of a 4-character axis name and a value, separated by whitespace and optional equals sign.Examples:
wght=200,wdth=140.5 wght 200 , wdth 140.5
- Parameters:
variations
- the new font variations, ornull
- Since:
- 1.16
-
setColorMode
-
getColorMode
-
setColorPalette
public void setColorPalette(int colorPalette) Sets the OpenType font color palette for the font options object. OpenType color fonts with a CPAL table may contain multiple palettes. The default color palette index isCOLOR_PALETTE_DEFAULT
.If palette_index is invalid, the default palette is used.
Individual colors within the palette may be overriden with cairo_font_options_set_custom_palette_color().
- Parameters:
colorPalette
- the palette index in the CPAL table- Since:
- 1.18
-
getColorPalette
public int getColorPalette()Gets the current OpenType color font palette for the font options object.- Returns:
- the palette index (an unsigned int)
- Since:
- 1.18
-
setCustomPaletteColor
public void setCustomPaletteColor(int index, double red, double green, double blue, double alpha) Sets a custom palette color for the font options object. This overrides the palette color at the specified color index. This override is independent of the selected palette index and will remain in place even ifsetColorPalette(int)
is called to change the palette index.It is only possible to override color indexes already in the font palette.
- Parameters:
index
- the index of the color to setred
- red component of colorgreen
- green component of colorblue
- blue component of coloralpha
- alpha component of color- Since:
- 1.18
-
getCustomPaletteColor
Gets the custom palette color for the color index for the font options object.- Parameters:
index
- the index of the color to get (an unsigned int)- Returns:
- the red, green, blue and alpha components of color
- Throws:
IndexOutOfBoundsException
- if no custom color exists for the color index- Since:
- 1.18
-
getType
public static org.gnome.glib.Type getType()Get the CairoFontOptions GType- Returns:
- the GType
-