Top Description Fields Constructors Methods
com.sun.prism.j2d

pack-priv final Class J2DFontFactory

extends Object
implements FontFactory
Class Inheritance
All Implemented Interfaces
com.sun.javafx.font.FontFactory
Imports
java.lang.reflect.Method, .InvocationTargetException, java.awt.Font, java.io.File, .FileInputStream, .InputStream, com.sun.javafx.font.FontResource, .PGFont, .FontFactory, com.sun.javafx.PlatformUtil

This is mostly just delegating, except for allowing for the registration of embedded fonts with Java 2D. Its possible it could also be check the names of all fonts that are being used are known to 2D but I'm not sure I need that.

Field Summary

Modifier and TypeField and Description
private static boolean
private static Method
pack-priv FontFactory

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public PGFont
public PGFont
createFont(String family, boolean bold, boolean italic, float size)

Implements com.sun.javafx.font.FontFactory.createFont.

public synchronized PGFont
deriveFont(PGFont
the original font.
font
,
boolean
the bold style for the new font.
bold
,
boolean
the italic style fort the new font.
italic
,
float
the size for the new font.
size
)

Implements com.sun.javafx.font.FontFactory.deriveFont.

Creates a new Font object by replicating the current Font object and applying a new bold style, italic style, and size to it.

pack-priv static Font
getCompositeFont(final Font srcFont)

Returns a composite font from the font passed in the argument.

public String[]
public String[]
public String[]
public boolean
public PGFont[]
loadEmbeddedFont(String
the name for font, it can be null.
name
,
InputStream
the stream from which to load the font.
fontStream
,
float
the size for the font.
size
,
boolean
whether the font should be register.
register
,
boolean
whether to load all fonts from a TTC
loadAll
)

Implements com.sun.javafx.font.FontFactory.loadEmbeddedFont.

Loads a font from the specified input stream.

public PGFont[]
loadEmbeddedFont(String
the name for font, it can be null.
name
,
String
the path from which to load the font.
path
,
float
the size for the font.
size
,
boolean
whether the font should be register.
register
,
boolean
whether to load all fonts from a TTC
loadAll
)

Implements com.sun.javafx.font.FontFactory.loadEmbeddedFont.

Loads a font from the specified path.

public static void
registerFont(final 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.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

compositeFontMethodsInitializedback to summary
private static boolean compositeFontMethodsInitialized
getCompositeFontUIResourceback to summary
private static Method getCompositeFontUIResource
prismFontFactoryback to summary
pack-priv FontFactory prismFontFactory

Constructor Detail

J2DFontFactoryback to summary
pack-priv J2DFontFactory(FontFactory fontFactory)

Method Detail

createFontback to summary
public PGFont createFont(String name, float size)

Implements com.sun.javafx.font.FontFactory.createFont.

Annotations
@Override
createFontback to summary
public PGFont createFont(String family, boolean bold, boolean italic, float size)

Implements com.sun.javafx.font.FontFactory.createFont.

Annotations
@Override
deriveFontback to summary
public synchronized PGFont deriveFont(PGFont font, boolean bold, boolean italic, float size)

Implements com.sun.javafx.font.FontFactory.deriveFont.

Doc from com.sun.javafx.font.FontFactory.deriveFont.

Creates a new Font object by replicating the current Font object and applying a new bold style, italic style, and size to it.

Note

bold and italic are hints.

Parameters
font:PGFont

the original font.

bold:boolean

the bold style for the new font.

italic:boolean

the italic style fort the new font.

size:float

the size for the new font.

Returns:PGFont

the new font.

Annotations
@Override
getCompositeFontback to summary
pack-priv static Font getCompositeFont(final Font srcFont)

Returns a composite font from the font passed in the argument.

Note

This method relies on Java2D's sun.* APIs which are subject to change. ALso this may be just a stop gap measure.

getFontFamilyNamesback to summary
public String[] getFontFamilyNames()

Implements com.sun.javafx.font.FontFactory.getFontFamilyNames.

Annotations
@Override
getFontFullNamesback to summary
public String[] getFontFullNames()

Implements com.sun.javafx.font.FontFactory.getFontFullNames.

Annotations
@Override
getFontFullNamesback to summary
public String[] getFontFullNames(String family)

Implements com.sun.javafx.font.FontFactory.getFontFullNames.

Annotations
@Override
isPlatformFontback to summary
public boolean isPlatformFont(String name)

Implements com.sun.javafx.font.FontFactory.isPlatformFont.

Annotations
@Override
loadEmbeddedFontback to summary
public PGFont[] loadEmbeddedFont(String name, InputStream fontStream, float size, boolean register, boolean loadAll)

Implements com.sun.javafx.font.FontFactory.loadEmbeddedFont.

Doc from com.sun.javafx.font.FontFactory.loadEmbeddedFont.

Loads a font 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 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.

Parameters
name:String

the name for font, it can be null.

fontStream:InputStream

the stream from which to load the font.

size:float

the size for the font.

register:boolean

whether the font should be register.

loadAll:boolean

whether to load all fonts from a TTC

Returns:PGFont[]

the Font, or null if the font cannot be created.

Annotations
@Override
loadEmbeddedFontback to summary
public PGFont[] loadEmbeddedFont(String name, String path, float size, boolean register, boolean loadAll)

Implements com.sun.javafx.font.FontFactory.loadEmbeddedFont.

Doc from com.sun.javafx.font.FontFactory.loadEmbeddedFont.

Loads a font from the specified path. If the load is successful such that the location is readable, and it represents a supported font format then a 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.

Parameters
name:String

the name for font, it can be null.

path:String

the path from which to load the font.

size:float

the size for the font.

register:boolean

whether the font should be register.

loadAll:boolean

whether to load all fonts from a TTC

Returns:PGFont[]

the Font, or null if the font cannot be created.

Annotations
@Override
registerFontback to summary
public static void registerFont(final 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.