public interface FontServer
FontServer provides some basic system-wide services such as listing available fonts.
Notes to creating implementations of FontServer:
Modifier and Type | Field and Description |
---|---|
static float |
OBLIQUE_SIMULATION_INVALID
Constant indicating that the font to be registered should not be allowed to simulate
oblique, italic, or backslant.
|
static float |
SMALL_CAP_SIMULATION_INVALID
Constant indicating that the font to be registered should not be allowed to simulate
small-caps.
|
static float |
SMALL_CAP_SIMULATION_NATIVE
Constant indicating that the font to be registered should be allowed to simulate
small-caps using the font's native x-height as the basis for the small-caps
percentage.
|
static float |
STRETCH_SIMULATION_INVALID
Constant indicating that the font to be registered should not be allowed to simulate
various font-stretch values.
|
Modifier and Type | Method and Description |
---|---|
java.util.List<Font> |
getAllFonts(boolean freeStandingFonts,
boolean systemFonts)
Returns a list of all Font instances.
|
Encoding |
getEncoding(java.lang.String name)
Returns an Encoding instance for the given name.
|
java.lang.String |
getFontFamilyForAlias(java.lang.String alias)
Finds the font-family that is associated with a given font-family alias.
|
java.util.List<java.lang.String> |
getSystemFontFamilyList()
Exposes the list of font families registered with the operating system.
|
java.util.List<java.awt.Font> |
getSystemFontList()
Exposes the list of fonts registered with the operating system.
|
boolean |
isRegisteredFont(java.lang.String fontID)
Indicates whether a font has already been registered for use by the
system.
|
boolean |
isRegisteredFontFamily(java.lang.String name)
Indicates whether a font-family has already been registered for use by
the system.
|
FontConsumer |
makeFontConsumer()
Creates an implementation-specific
FontConsumer instance. |
void |
registerFont(java.lang.String fontID,
javax.activation.DataSource fontFileSource,
javax.activation.DataSource metricsFileSource,
java.lang.String collectionID,
Font.Embedding requestedEmbedding,
java.lang.String systemName)
Register a font for use by the system.
|
void |
registerFontDescription(java.lang.String fontFamily,
java.lang.String fontID,
Encoding encoding,
Font.Style style,
Font.Weight weight,
Font.Variant variant,
Font.Stretch stretch,
float simulatedSmallCaps,
float simulatedOblique,
float simulatedBackslant,
float[] simulatedStretch)
Register a font description for use by the system.
|
void |
registerFontFamily(java.lang.String name)
Register a font-family for use by the system.
|
void |
registerFontFamilyAlias(java.lang.String alias,
java.lang.String realFamily)
Add a font-family alias.
|
static final float SMALL_CAP_SIMULATION_INVALID
static final float SMALL_CAP_SIMULATION_NATIVE
static final float OBLIQUE_SIMULATION_INVALID
static final float STRETCH_SIMULATION_INVALID
java.util.List<Font> getAllFonts(boolean freeStandingFonts, boolean systemFonts)
freeStandingFonts
- Set to true to include free-standing fonts in
the returned array.systemFonts
- Set to true to include system fonts in the returned
array.java.util.List<java.lang.String> getSystemFontFamilyList()
java.util.List<java.awt.Font> getSystemFontList()
Encoding getEncoding(java.lang.String name)
name
- The name of the Encoding instance that is sought.void registerFontFamily(java.lang.String name) throws FontException
name
- The name of the font-family (e.g. "Courier").FontException
- If the font-family is already registered.boolean isRegisteredFontFamily(java.lang.String name)
name
- The name of the font-family (e.g. "Courier").void registerFontFamilyAlias(java.lang.String alias, java.lang.String realFamily) throws FontException
alias
- The name of the font-family alias (e.g. "sans-serif").realFamily
- The name of the real font-family to which this alias
should be associated (e.g. "Helvetica").FontException
- If the font-family alias is already registered, or
if realFamily
is not a registered font-family.java.lang.String getFontFamilyForAlias(java.lang.String alias)
alias
- The name of the font-family alias.alias
.void registerFont(java.lang.String fontID, javax.activation.DataSource fontFileSource, javax.activation.DataSource metricsFileSource, java.lang.String collectionID, Font.Embedding requestedEmbedding, java.lang.String systemName) throws FontException
fontID
- A unique ID for this font (e.g. "Courier-Bold").fontFileSource
- Source of the file containing the font, if any.metricsFileSource
- Source of the file containing the font metrics, if any.
This is null for TrueType and OpenType fonts.collectionID
- For TrueType collections, indicates which font in the collection corresponds to this font.requestedEmbedding
- The requested font embedding for the font to be registered.systemName
- For system fonts only, this is the name that should be supplied to the operating system font
registry to obtain the font from it. For other fonts, set this to null.FontException
- If a font with this fontID
is already registered.boolean isRegisteredFont(java.lang.String fontID)
fontID
- The unique font ID for the font (e.g. "Courier-Bold").fontID
is already
registered.void registerFontDescription(java.lang.String fontFamily, java.lang.String fontID, Encoding encoding, Font.Style style, Font.Weight weight, Font.Variant variant, Font.Stretch stretch, float simulatedSmallCaps, float simulatedOblique, float simulatedBackslant, float[] simulatedStretch) throws FontException
fontFamily
- The name of the font-family in which this font should
be registered.fontID
- The font ID for the font that should be registered.encoding
- The encoding, if any, that should be used by this
font description. Set this value to null unless you wish to override
the encoding for this font.style
- One of Font.Style.NORMAL
,
Font.Style.ITALIC
,
Font.Style.OBLIQUE
, or
Font.Style.BACKSLANT
.weight
- One of Font.Weight.EXTREMELY_LIGHT
,
Font.Weight.VERY_LIGHT
,
Font.Weight.LIGHT
,
Font.Weight.NORMAL
,
Font.Weight.DARK
,
Font.Weight.SEMI_BOLD
,
Font.Weight.BOLD
,
Font.Weight.EXTRA_BOLD
,or
Font.Weight.BLACK
.variant
- One of Font.Variant.NORMAL
, or
Font.Variant.SMALL_CAPS
.stretch
- One of Font.Stretch.ULTRA_CONDENSED
,
Font.Stretch.EXTRA_CONDENSED
,
Font.Stretch.CONDENSED
,
Font.Stretch.SEMI_CONDENSED
,
Font.Stretch.NORMAL
,
Font.Stretch.SEMI_EXPANDED
,
Font.Stretch.EXPANDED
,
Font.Stretch.EXTRA_EXPANDED
, or
Font.Stretch.ULTRA_EXPANDED
.simulatedSmallCaps
- To prevent this font-description from being
used to simulate small-caps, set this value to
SMALL_CAP_SIMULATION_INVALID
.
To allow it to simulate small-caps using the font's native x-height computation, set this
value to SMALL_CAP_SIMULATION_NATIVE
.
Otherwise, set it to the percentage which should be applied to the
font-size for the small caps. For example, if set to 80%, and the
font-size is 12 points, the resulting small-caps will be presented at
9.6 points.simulatedOblique
- To prevent this font-description from being
used to simulate oblique, set this value to OBLIQUE_SIMULATION_INVALID
.
Otherwise, set it to the number of degrees clockwise that the font should
be skewed to simulate oblique.simulatedBackslant
- To prevent this font-description from being
used to simulate backslant, set this value to OBLIQUE_SIMULATION_INVALID
.
Otherwise, set it to the number of degrees counterclockwise that the font
should be skewed to simulate backslant.simulatedStretch
- Array containing percentages by which the font
should be stretched horizontally for various font-stretch values.
Values greater than 100 will result in wider characters.
Values less than 100 will result in narrower characters.
Invalid or unset amounts are indicated by the value
STRETCH_SIMULATION_INVALID
.
Element 0 corresponds to ultra-condensed (the narrowest value), and
element 7 corresponds to ultra-expanded (the widest value).
Note that there is no element for "normal", since that does not need to
be simulated.FontException
- If fontFamily
or fontID
are not already registered.FontConsumer makeFontConsumer()
FontConsumer
instance.FontConsumer
instance.This documentation was created 2017-01-24 at 21:26 GMT by The aXSL Group and may be freely copied. See license for details.