final class J2DFontFactory extends java.lang.Object implements FontFactory
Modifier and Type | Field and Description |
---|---|
private static boolean |
compositeFontMethodsInitialized |
private static java.lang.reflect.Method |
getCompositeFontUIResource |
(package private) FontFactory |
prismFontFactory |
DEFAULT_FULLNAME
Constructor and Description |
---|
J2DFontFactory(FontFactory fontFactory) |
Modifier and Type | Method and Description |
---|---|
PGFont |
createFont(java.lang.String family,
boolean bold,
boolean italic,
float size) |
PGFont |
createFont(java.lang.String name,
float size) |
PGFont |
deriveFont(PGFont font,
boolean bold,
boolean italic,
float size)
Creates a new Font object by replicating the current Font object
and applying a new bold style, italic style, and size to it.
|
(package private) static java.awt.Font |
getCompositeFont(java.awt.Font srcFont)
Returns a composite font from the font passed in the argument.
|
java.lang.String[] |
getFontFamilyNames() |
java.lang.String[] |
getFontFullNames() |
java.lang.String[] |
getFontFullNames(java.lang.String family) |
boolean |
hasPermission() |
boolean |
isPlatformFont(java.lang.String name) |
PGFont |
loadEmbeddedFont(java.lang.String name,
java.io.InputStream fontStream,
float size,
boolean register)
Loads a font from the specified input stream.
|
PGFont |
loadEmbeddedFont(java.lang.String name,
java.lang.String path,
float size,
boolean register)
Loads a font from the specified path.
|
static void |
registerFont(FontResource fr)
Printing uses the 2D pipeline which isn't initialised until
printing begins, so grabs a copy of the file holding an
embedded font to 2D on first use.
|
FontFactory prismFontFactory
private static boolean compositeFontMethodsInitialized
private static java.lang.reflect.Method getCompositeFontUIResource
J2DFontFactory(FontFactory fontFactory)
public PGFont createFont(java.lang.String name, float size)
createFont
in interface FontFactory
public PGFont createFont(java.lang.String family, boolean bold, boolean italic, float size)
createFont
in interface FontFactory
public PGFont deriveFont(PGFont font, boolean bold, boolean italic, float size)
FontFactory
NOTE: bold and italic are hints.
deriveFont
in interface FontFactory
font
- the original font.bold
- the bold style for the new font.italic
- the italic style fort the new font.size
- the size for the new font.public java.lang.String[] getFontFamilyNames()
getFontFamilyNames
in interface FontFactory
public java.lang.String[] getFontFullNames()
getFontFullNames
in interface FontFactory
public java.lang.String[] getFontFullNames(java.lang.String family)
getFontFullNames
in interface FontFactory
public boolean isPlatformFont(java.lang.String name)
isPlatformFont
in interface FontFactory
public final boolean hasPermission()
hasPermission
in interface FontFactory
public PGFont loadEmbeddedFont(java.lang.String name, java.io.InputStream fontStream, float size, boolean register)
FontFactory
PGFont
object will be returned.
Any failure such as abbreviated input, or an unsupported font format
will result in a null
return. It is the application's
responsibility to check this before use.
If the register
flag is true, and the loading operation
completes successfully, then the returned font is 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.
When the font is registered, an alternative name
can be
supplied. This name can be used for creation by available constructors
and factory methods.
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.
This method does not close the input stream.
loadEmbeddedFont
in interface FontFactory
name
- the name for font, it can be null
.fontStream
- the stream from which to load the font.size
- the size for the font.register
- whether the font should be register.public static void registerFont(FontResource fr)
public PGFont loadEmbeddedFont(java.lang.String name, java.lang.String path, float size, boolean register)
FontFactory
PGFont
object will be returned.
Any failure such as a file 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.
If the register
flag is true, and the loading operation
completes successfully, then the returned font is 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.
When the font is registered, an alternative name
can be
supplied. This name can be used for creation by available constructors
and factory methods.
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.
loadEmbeddedFont
in interface FontFactory
name
- the name for font, it can be null
.path
- the path from which to load the font.size
- the size for the font.register
- whether the font should be register.static java.awt.Font getCompositeFont(java.awt.Font srcFont)