The Font class represents fonts, which are used to render text on
screen.
The size of a Font is described as being specified in points
which are a real world measurement of approximately 1/72 inch.
Given that fonts scale with the rendering transform as determined
by the transform attributes of a Node using the Font
and its ancestors, the size will actually be relative to the local
coordinate space of the node, which should provide coordinates
similar to the size of a point if no scaling transforms are present
in the environment of the node.
Note that the real world distances specified by the default coordinate
system only approximate point sizes as a rule of thumb and are typically
defaulted to screen pixels for most displays.
For more information see javafx. for more information
on the default coordinate system
| Modifier and Type | Field and Description |
|---|---|
| private static Font | |
| private static final String | |
| private static final String | |
| private static float | defaultSystemFontSize
The default font for this platform. |
| private String | |
| private int | hash
The cached hash code, used to improve performance in situations where we cache fonts, such as in the CSS routines. |
| private String | |
| private Object | |
| private double | |
| private String |
| Access | Constructor and Description |
|---|---|
| public | |
| public | |
| private |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | Returns: true if this object is equal to the obj argument; false otherwise.the reference object with which to compare. obj)Overrides java. Indicates whether some other object is "equal to" this one. |
| public static Font | Returns: The font that best fits the specified requirements.The family of the font family, FontWeight The weight of the font weight, FontPosture The posture or posture of the font posture, double The point size of the font. This can be a fractional value,
but must not be negative. If the size is < 0 the default size will be
used. size)Searches for an appropriate font based on the font family name and weight and posture style. |
| public static Font | Returns: The font that best fits the specified requirements.The family of the font family, FontWeight The weight of the font weight, double The point size of the font. This can be a fractional value,
but must not be negative. If the size is < 0 the default size will be
used. size)Searches for an appropriate font based on the font family name and weight style. |
| public static Font | Returns: The font that best fits the specified requirements.The family of the font family, FontPosture The posture or posture of the font posture, double The point size of the font. This can be a fractional value,
but must not be negative. If the size is < 0 the default size will be
used. size)Searches for an appropriate font based on the font family name and posture style. |
| public static Font | Returns: The font that best fits the specified requirements.The family of the font family, double The point size of the font. This can be a fractional value,
but must not be negative. If the size is < 0 the default size will be
used. size)Searches for an appropriate font based on the font family name and size. |
| public static Font | |
| public static Font | Returns: The font that best fits the specified requirements.The point size of the font. This can be a fractional value,
but must not be negative. If the size is < 0 the default size will be
used. size)Searches for an appropriate font based on the default font family name and given font size. |
| public static synchronized Font | Returns: The default font.Gets the default font which will be from the family "System", and typically the style "Regular", and be of a size consistent with the user's desktop environment, to the extent that can be determined. |
| private static float | |
| public static List | Returns: The list containing all available font families.Gets all the font families installed on the user's system, including any application fonts or SDK fonts. |
| public final String | |
| public static List | Returns: The list containing all available fonts.Gets the names of all fonts that are installed on the users system, including any application fonts and SDK fonts. |
| public static List | Returns: The list containing the fonts for the given family.the font family family)Gets the names of all fonts in the specified font family that are installed on the users system, including any application fonts and SDK fonts. |
| public final String | |
| pack-priv Object | |
| public final double | |
| public final String | Returns: The style name of this font.The font specified string describing the style within the font family. |
| public int | Returns: a hash code for thisFont object.Overrides java. Returns a hash code for this |
| public static Font | |
| public static Font | Returns: the Font, or null if the font cannot be created.stream from which to load the font. in, double of the returned font. size)Loads a font resource from the specified input stream. |
| private static Font[] | |
| public static Font[] | |
| public static Font[] | Returns: array of Font, or null if the fonts cannot be created.stream from which to load the fonts. in, double of the returned fonts. size)Loads font resources from the specified input stream. |
| pack-priv static Font | |
| pack-priv void | |
| public String | toString()
Overrides java. Converts this |
| DEFAULT | back to summary |
|---|---|
| private static Font DEFAULT | |
| DEFAULT_FAMILY | back to summary |
|---|---|
| private static final String DEFAULT_FAMILY | |
| DEFAULT_FULLNAME | back to summary |
|---|---|
| private static final String DEFAULT_FULLNAME | |
| defaultSystemFontSize | back to summary |
|---|---|
| private static float defaultSystemFontSize The default font for this platform. This is used whenever a font is not specifically set on a Text node or overridden by CSS. | |
| family | back to summary |
|---|---|
| private String family | |
| hash | back to summary |
|---|---|
| private int hash The cached hash code, used to improve performance in situations where we cache fonts, such as in the CSS routines. | |
| name | back to summary |
|---|---|
| private String name | |
| nativeFont | back to summary |
|---|---|
| private Object nativeFont | |
| size | back to summary |
|---|---|
| private double size | |
| style | back to summary |
|---|---|
| private String style | |
| Font | back to summary |
|---|---|
| public Font(double size) Constructs a font using the default face "System". The underlying font used is determined by the implementation based on the typical UI font for the current UI environment.
| |
| Font | back to summary |
|---|---|
| public Font(String name, double size) Constructs a font using the specified full face name and size
| |
| Font | back to summary |
|---|---|
| private Font(Object f, String family, String name, String style, double size) Private constructor for internal implementation | |
| equals | back to summary |
|---|---|
| public boolean equals(Object obj) Overrides java. Indicates whether some other object is "equal to" this one. | |
| font | back to summary |
|---|---|
| public static Font font(String family, FontWeight weight, FontPosture posture, double size) Searches for an appropriate font based on the font family name and weight and posture style. This method is not guaranteed to return a specific font, but does its best to find one that fits the specified requirements. A null or empty value for family allows the implementation to select any suitable font.
| |
| font | back to summary |
|---|---|
| public static Font font(String family, FontWeight weight, double size) Searches for an appropriate font based on the font family name and weight style. This method is not guaranteed to return a specific font, but does its best to find one that fits the specified requirements. A null or empty value for family allows the implementation to select any suitable font.
| |
| font | back to summary |
|---|---|
| public static Font font(String family, FontPosture posture, double size) Searches for an appropriate font based on the font family name and posture style. This method is not guaranteed to return a specific font, but does its best to find one that fits the specified requirements. A null or empty value for family allows the implementation to select any suitable font.
| |
| font | back to summary |
|---|---|
| public static Font font(String family, double size) Searches for an appropriate font based on the font family name and size. This method is not guaranteed to return a specific font, but does its best to find one that fits the specified requirements. A null or empty value for family allows the implementation to select any suitable font. | |
| font | back to summary |
|---|---|
| public static Font font(String family) Searches for an appropriate font based on the given font family name and default font size. This method is not guaranteed to return a specific font, but does its best to find one that fits the specified requirements. A null or empty value for family allows the implementation to select any suitable font. | |
| font | back to summary |
|---|---|
| public static Font font(double size) Searches for an appropriate font based on the default font family name and given font size. This method is not guaranteed to return a specific font, but does its best to find one that fits the specified requirements.
| |
| getDefault | back to summary |
|---|---|
| public static synchronized Font getDefault() Gets the default font which will be from the family "System", and typically the style "Regular", and be of a size consistent with the user's desktop environment, to the extent that can be determined.
| |
| getDefaultSystemFontSize | back to summary |
|---|---|
| private static float getDefaultSystemFontSize() | |
| getFamilies | back to summary |
|---|---|
| public static List Gets all the font families installed on the user's system, including any application fonts or SDK fonts. This call has performance considerations as looking up all of the fonts may be an expensive operation the first time. | |
| getFamily | back to summary |
|---|---|
| public final String getFamily() Returns the family of this font.
| |
| getFontNames | back to summary |
|---|---|
| public static List Gets the names of all fonts that are installed on the users system, including any application fonts and SDK fonts. This call has performance considerations as looking up all of the fonts may be an expensive operation the first time. | |
| getFontNames | back to summary |
|---|---|
| public static List Gets the names of all fonts in the specified font family that are installed on the users system, including any application fonts and SDK fonts. This call has performance considerations as looking up all of the fonts may be an expensive operation the first time. | |
| getName | back to summary |
|---|---|
| public final String getName() The full font name. This name includes both the family name and the style variant within that family. For example, for a plain Arial font this would be "Arial Regular" and for a bolded Arial font this would be "Arial Bold". The precise name to use when loading a font is defined within each font file as the full font name. For example, "Proxima Nova ExtraCondensed Bold Italic" would refer to a specific Proxima Nova font. A null or empty name allows the implementation to select any suitable font.
There is a single unified way to load all of application supplied
(via
Note that if you wish to locate a font by font family and style
then you can use one of the
| |
| getNativeFont | back to summary |
|---|---|
| pack-priv Object getNativeFont() | |
| getSize | back to summary |
|---|---|
| public final double getSize() The point size for this font. This may be a fractional value such as
| |
| getStyle | back to summary |
|---|---|
| public final String getStyle() The font specified string describing the style within the font family.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Returns a hash code for this
| |
| loadFont | back to summary |
|---|---|
| public static Font loadFont(String urlStr, double size) Loads a font resource from the specified URL. If the load is successful
such that the location is readable, and it represents a supported
font format then a
Any failure such as a malformed URL being unable to locate or read
from the resource, or if it doesn't represent a font, will result in
a On a successful (non-null) return the font will be registered with the FX graphics system for creation by available constructors and factory methods, and the application should use it in this manner rather than calling this method again, which would repeat the overhead of downloading and installing the font.
The font If the URL represents a local disk file, then no copying is performed and the font file is required to persist for the lifetime of the application. Updating the file in any manner will result in unspecified and likely undesired behaviours. | |
| loadFont | back to summary |
|---|---|
| public static Font loadFont(InputStream in, double size) Loads a font resource from the specified input stream.
If the load is successful such that the stream can be
fully read, and it represents a supported font format then a
Any failure such as abbreviated input, or an unsupported font format
will result in a On a successful (non-null) return the font will be registered with the FX graphics system for creation by available constructors and factory methods, and the application should use it in this manner rather than calling this method again, which would repeat the overhead of re-reading and installing the font.
The font This method does not close the input stream.
| |
| loadFontInternal | back to summary |
|---|---|
| private static Font[] loadFontInternal(String urlStr, double size, boolean loadAll) | |
| loadFonts | back to summary |
|---|---|
| public static Font[] loadFonts(String urlStr, double size) Loads font resources from the specified URL. If the load is successful
such that the location is readable, and it represents a supported
font format then an array of The use case for this method is for loading all fonts from a TrueType Collection (TTC).
Any failure such as a malformed URL being unable to locate or read
from the resource, or if it doesn't represent a font, will result in
a On a successful (non-null) return the fonts will be registered with the FX graphics system for creation by available constructors and factory methods, and the application should use it in this manner rather than calling this method again, which would repeat the overhead of downloading and installing the fonts.
The font If the URL represents a local disk file, then no copying is performed and the font file is required to persist for the lifetime of the application. Updating the file in any manner will result in unspecified and likely undesired behaviours. | |
| loadFonts | back to summary |
|---|---|
| public static Font[] loadFonts(InputStream in, double size) Loads font resources from the specified input stream.
If the load is successful such that the stream can be
fully read, and it represents a supported font format then
an array of The use case for this method is for loading all fonts from a TrueType Collection (TTC).
Any failure such as abbreviated input, or an unsupported font format
will result in a On a successful (non-null) return the fonts will be registered with the FX graphics system for creation by available constructors and factory methods, and the application should use it in this manner rather than calling this method again, which would repeat the overhead of re-reading and installing the fonts.
The font This method does not close the input stream.
| |
| nativeFont | back to summary |
|---|---|
| pack-priv static Font nativeFont(Object f, String name, String family, String style, double size) | |
| setNativeFont | back to summary |
|---|---|
| pack-priv void setNativeFont(Object f, String nam, String fam, String styl) | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Converts this
| |