Font-related utilities.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final classThe list of all supported features. -
Method Summary
Modifier and TypeMethodDescriptionbooleancanDisplayWithoutFallback(Font font, int codePoint) Checks if the given font itself has a glyph for the specified character.deriveFontWithFeatures(Font font, String... features) getAvailableFeatures(Font font) This method returns a set of OpenType features supported by the given fontString[]getEnabledFeatures(Font font) This method returns an array of features for the given font, set viaderiveFontWithFeatures(java.awt.Font, java.lang.String...).Get subpixel resolution for rendering text with greyscale antialiasing, set with-Djava2d.font.subpixelResolution=NxM, with integers between 1 and 16 instead of N and M.
-
Method Details
-
deriveFontWithFeatures
This method derives a newFontobject with a set of features. Feature syntax is<name>or<name>=<int>, likekern, oraalt=2. This method does not preserve features of the original font, they are completely overridden, if you need to append features to the font, usegetEnabledFeatures(Font).- Parameters:
font- basic fontfeatures- set of OpenType's features- Returns:
- new font
-
getEnabledFeatures
This method returns an array of features for the given font, set viaderiveFontWithFeatures(java.awt.Font, java.lang.String...). Feature syntax is<name>or<name>=<int>, likekern, oraalt=2.- Parameters:
font- the font- Returns:
- an array of features for the font
-
getAvailableFeatures
This method returns a set of OpenType features supported by the given font- Parameters:
font- the font- Returns:
- set of supported features
-
getSubpixelResolution
Dimension getSubpixelResolution()Get subpixel resolution for rendering text with greyscale antialiasing, set with-Djava2d.font.subpixelResolution=NxM, with integers between 1 and 16 instead of N and M. This only affects text rendered via glyph cache. Value of NxM means that each glyph has rasterized images for N distinct positions horizontally and M positions vertically. This effectively increases quality of glyph spacing in each direction at the cost of N*M times increased memory consumption.- Returns:
- subpixel resolution (N, M)
-
canDisplayWithoutFallback
@Extension(CAN_DISPLAY_WITHOUT_FALLBACK) boolean canDisplayWithoutFallback(Font font, int codePoint) Checks if the given font itself has a glyph for the specified character. UnlikeFont.canDisplay(int), this method doesn't take into account fallback fonts which may be substituted by the platform for characters missing in the requested font. For example, on macOSFont.canDisplay(int)returnstruefor any character which can be displayed by any of the system fallback fonts. For logical fonts, all their component fonts are considered.- Parameters:
font- the fontcodePoint- the character (Unicode code point) for which a glyph is needed- Returns:
trueif the font itself has a glyph for the character;falseotherwise- Throws:
IllegalArgumentException- if the code point is not a valid Unicode code point- See Also:
-