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 Font object will be returned.
If a security manager is present, the application
must have both permission to read from the specified URL location
and the javafx.util.FXPermission "loadFont".
If the application does not have permission to read from the specified
URL location, then null is returned.
If the application does not have the "loadFont" permission then this method
will return the default system font with the specified font size.
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 null return. It is the application's responsibility
to check this before use.
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 size parameter is a convenience so that in
typical usage the application can directly use the returned (non-null)
font rather than needing to create one via a constructor.
Invalid sizes are those <=0 and will result in a default size.
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.
urlStr | from which to load the font, specified as a String. | |
size | of the returned font. |
Diagram: Font