Interface Font
-
- All Superinterfaces:
java.io.Serializable
- All Known Implementing Classes:
Base14Font
,FontImpl
,MemoryFont
,ResourceFont
public interface Font extends java.io.Serializable
The basic interface for all public font interaction.This class provides the basic functionality common to all Fonts.
Metrics
Metrics are expressed in a metric space, which is related to the em space by the matrix (1/ux 0, 0, 1/uy), where ux is the units per em in the X direction and uy is the units per em in the Y direction. Those two quantities can be retrieved by the
getUnitsPerEmX()
andgetUnitsPerEmY()
methods. The values ux and uy may or may not be related to any data in the font; they are only guaranteed to be compatible with the values returned by methods that retrieve metrics. In other words, if x is an horizontal metric returned by some method, only the value x / ux is meaningful, and the specific values x and ux may change from one execution to the next (ux is constant for the life of a Font object).Very often (but not always), the font metrics stored in the font are expressed in the metric space (or conversely, the metric space is selected to be the space in which the raw font data is expressed). Returning metrics in the metric space, instead of in the em space, allows the conversion to the em space to be performed less often (e.g. only after metrics such as the advance width have been cumulated). Another benefit is that the conversion to em space is often followed by a conversion to some kind of user space (e.g. scaling by the point size, or expressing the result in some other units than points); those further conversions can be combined with the metric to em space conversion, resulting in less computations.
Glyphs
A font contains a number of glyphs, which are identified by their gids. Gids are by construction in the range [0, numGlyphs-1[. The glyph with gid 0 has a special meaning: it is the .notdef glyph, which is used, e.g. when a font contains no glyph for a given character.
Synchronization
Implementations of this interface are synchronized as needed, so that users can use a Font in multiple threads without synchronization on their side.
Handling of symbolic fonts
A symbolic font is an OpenType font (without or without OpenType tables) which does not have Unicode cmap, but has a Microsoft/Symbol cmap. The fonts Wingdings, Webdings, and Symbol that are provided by Microsoft are symbolic fonts. The symbol cmaps, typically maps the code points 0xF0 yz
AFE behaves as if those fonts had a Unicode cmap. If 0xF0 yz is mapped in the symbolic cmap, then both U+F0 yz and U+00 yz are mapped in the Unicode cmap. The purpose of this double mapping is to approximate the behavior of GDI and applications such as Word.
The first set of mappings, from U+F0 yz , are rather innocuous, as those code points are Private Use Area, and have very little semantic. The second set of mappings, from U+00 yz , are very problematic, because the the semantic of the source characters is typically not applicable. This is particulary true for the glyphs mapped from U+0000 .. U+001F and U+0080 .. U+009F (because those characters have the semantic of control character) and the glyph mapped from U+00AD SOFT HYPHEN (which is a Cf character that is not normally rendered). Other strange behavior can occur in bidi processing and line breaking processing. To help clients avoid those problems, the
isSymbolic()
method returns true for symbolic fonts.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
canEmbedForEditting()
boolean
canEmbedForPrintAndPreview()
Subset
createSubset()
Create a subset for this font.Rect
getCoolTypeGlyphBBox(int glyphID)
Emulates the CoolType API CCTFontInstance::GetBBox.Rect
getCoolTypeIcfBox()
Emulates the CoolType API CTFontDict:GetICFBox.Rect
getCoolTypeIdeoEmBox()
Emulates the CoolType API CTFontDict:GetIdeoEmBox.LineMetrics
getCoolTypeLineMetrics()
Emulates the CoolType API CTFontDict:GetHorizontalMetrics.CoolTypeScript
getCoolTypeScript()
Emulates the CoolType API CCTFontDict::GetWritingScript.UnderlineMetrics
getCoolTypeUnderlineMetrics()
Emulates the CoolType API CTFontDict:GetUnderlineInfo.CSS20FontDescription[]
getCSS20FontDescription()
Get the CSS20FontDescriptions for this font.FXGFontDescription[]
getFXGFontDescription()
Get all of the FXG descriptions for the font.FXGFontDescription[]
getFXGFontDescription(Platform platform)
Get all of the FXG descriptions for this font on the given platform.FXGFontDescription[]
getFXGFontDescription(Platform platform, ULocale locale)
Get all of the FXG descriptions for this font on the given platform and for the given locale.LineMetrics
getLineMetrics()
Return the line metrics for this font, as expressed by the font designer.PDFFontDescription
getPDFFontDescription()
Get the PDFFontDescription for this font.PlatformFontDescription[]
getPlatformFontDescription()
Get all of the Platform descriptions for the font.PlatformFontDescription[]
getPlatformFontDescription(Platform platform)
Get all of the Platform descriptions for this font on the given platform.PlatformFontDescription[]
getPlatformFontDescription(Platform platform, ULocale locale)
Get all of the Platform descriptions for this font on the given platform and for the given locale.PostscriptFontDescription[]
getPostscriptFontDescription()
Get the PostscriptFontDescriptions for this font.CSS20FontDescription
getPreferredCSS20FontDescription()
Get the preferred CSS20FontDescriptions for this font.SWFFont4Description
getSWFFont4Description()
Fetch data needed to construct a DefineFont4 tag in SWF.SWFFontDescription
getSWFFontDescription()
Fetch data needed to construct a DefineFont2 or 3 tag in SWF.double
getUnitsPerEmX()
Return the units per em in the X direction.double
getUnitsPerEmY()
Return the units per em in the Y direction.XDCFontDescription
getXDCFontDescription()
Get the XDCFontDescription for this font.boolean
hasCoolTypeProportionalRoman()
Emulates the CoolType API CTFontDict::hasPropRoman.boolean
isSymbolic()
Tell whether the font is symbolic.
-
-
-
Method Detail
-
getUnitsPerEmX
double getUnitsPerEmX() throws UnsupportedFontException, InvalidFontException, FontLoadingException
Return the units per em in the X direction.Unless otherwise specified, horizontal metrics returned by AFE are expressed in a metric space, and must be divided by the units per em in the X direction to get em values.
-
getUnitsPerEmY
double getUnitsPerEmY() throws UnsupportedFontException, InvalidFontException, FontLoadingException
Return the units per em in the Y direction.Unless otherwise specified, vertical metrics returned by AFE are expressed in a metric space, and must be divided by the units per em in the Y direction to get em values.
-
getLineMetrics
LineMetrics getLineMetrics() throws UnsupportedFontException, InvalidFontException, FontLoadingException
Return the line metrics for this font, as expressed by the font designer.The metrics are expressed in the metric space of the font.
Some font formats do not support the notion of line metrics, and in those cases, this method returns null.
See also the
getCoolTypeLineMetrics()
method.
-
getCoolTypeLineMetrics
LineMetrics getCoolTypeLineMetrics() throws UnsupportedFontException, InvalidFontException, FontLoadingException
Emulates the CoolType API CTFontDict:GetHorizontalMetrics.The metrics are expressed in the metric space of the font.
See also the
getLineMetrics()
method.
-
getCoolTypeGlyphBBox
Rect getCoolTypeGlyphBBox(int glyphID) throws UnsupportedFontException, InvalidFontException, FontLoadingException
Emulates the CoolType API CCTFontInstance::GetBBox. In particular, it calculates all bboxes instead of relying on metrics in the font.The metrics are expressed in the metric space of the font.
-
getCoolTypeUnderlineMetrics
UnderlineMetrics getCoolTypeUnderlineMetrics() throws UnsupportedFontException, InvalidFontException, FontLoadingException
Emulates the CoolType API CTFontDict:GetUnderlineInfo.The metrics are expressed in the metric space of the font.
-
getCoolTypeScript
CoolTypeScript getCoolTypeScript() throws FontLoadingException, InvalidFontException, UnsupportedFontException
Emulates the CoolType API CCTFontDict::GetWritingScript.- Returns:
- The "primary script" associated with this font.
- Throws:
FontLoadingException
InvalidFontException
UnsupportedFontException
-
getCoolTypeIdeoEmBox
Rect getCoolTypeIdeoEmBox() throws UnsupportedFontException, InvalidFontException, FontLoadingException
Emulates the CoolType API CTFontDict:GetIdeoEmBox.The metrics are expressed in the metric space of the font.
-
hasCoolTypeProportionalRoman
boolean hasCoolTypeProportionalRoman() throws UnsupportedFontException, InvalidFontException, FontLoadingException
Emulates the CoolType API CTFontDict::hasPropRoman.- Returns:
- true if the font contains proportional roman glyphs.
- Throws:
UnsupportedFontException
InvalidFontException
FontLoadingException
-
getCoolTypeIcfBox
Rect getCoolTypeIcfBox() throws UnsupportedFontException, InvalidFontException, FontLoadingException
Emulates the CoolType API CTFontDict:GetICFBox.The metrics are expressed in the metric space of the font.
-
isSymbolic
boolean isSymbolic() throws UnsupportedFontException, InvalidFontException, FontLoadingException
Tell whether the font is symbolic.
-
canEmbedForPrintAndPreview
boolean canEmbedForPrintAndPreview() throws InvalidFontException, UnsupportedFontException, FontLoadingException
-
canEmbedForEditting
boolean canEmbedForEditting() throws InvalidFontException, UnsupportedFontException, FontLoadingException
-
createSubset
Subset createSubset() throws InvalidFontException, UnsupportedFontException, FontLoadingException
Create a subset for this font.
-
getSWFFontDescription
SWFFontDescription getSWFFontDescription() throws InvalidFontException, UnsupportedFontException, FontLoadingException
Fetch data needed to construct a DefineFont2 or 3 tag in SWF.
-
getSWFFont4Description
SWFFont4Description getSWFFont4Description() throws InvalidFontException, UnsupportedFontException, FontLoadingException
Fetch data needed to construct a DefineFont4 tag in SWF. Returns null if a font does not support DefineFont4.
-
getPDFFontDescription
PDFFontDescription getPDFFontDescription() throws InvalidFontException, UnsupportedFontException, FontLoadingException
Get the PDFFontDescription for this font.
-
getXDCFontDescription
XDCFontDescription getXDCFontDescription() throws InvalidFontException, UnsupportedFontException, FontLoadingException
Get the XDCFontDescription for this font.
-
getPostscriptFontDescription
PostscriptFontDescription[] getPostscriptFontDescription() throws InvalidFontException, UnsupportedFontException, FontLoadingException
Get the PostscriptFontDescriptions for this font.
-
getCSS20FontDescription
CSS20FontDescription[] getCSS20FontDescription() throws InvalidFontException, UnsupportedFontException, FontLoadingException
Get the CSS20FontDescriptions for this font.
-
getPreferredCSS20FontDescription
CSS20FontDescription getPreferredCSS20FontDescription() throws InvalidFontException, UnsupportedFontException, FontLoadingException
Get the preferred CSS20FontDescriptions for this font. Returns null if there is no CSS20 description for this font.
-
getFXGFontDescription
FXGFontDescription[] getFXGFontDescription() throws InvalidFontException, UnsupportedFontException, FontLoadingException
Get all of the FXG descriptions for the font.- Returns:
- an array of all the FXG descriptions for the font
or
null
if there are none - Throws:
InvalidFontException
UnsupportedFontException
FontLoadingException
-
getFXGFontDescription
FXGFontDescription[] getFXGFontDescription(Platform platform) throws InvalidFontException, UnsupportedFontException, FontLoadingException
Get all of the FXG descriptions for this font on the given platform.- Parameters:
platform
- the platform to get descriptions for- Returns:
- an array of all of the specified FXG descriptions for the font
or
null
if there are none - Throws:
InvalidFontException
UnsupportedFontException
FontLoadingException
-
getFXGFontDescription
FXGFontDescription[] getFXGFontDescription(Platform platform, ULocale locale) throws InvalidFontException, UnsupportedFontException, FontLoadingException
Get all of the FXG descriptions for this font on the given platform and for the given locale.- Parameters:
platform
- the platform to get descriptions forlocale
- the locale to get descriptions for- Returns:
- an array of all of the specified FXG descriptions for the font
or
null
if there are none - Throws:
InvalidFontException
UnsupportedFontException
FontLoadingException
-
getPlatformFontDescription
PlatformFontDescription[] getPlatformFontDescription() throws InvalidFontException, UnsupportedFontException, FontLoadingException
Get all of the Platform descriptions for the font.- Returns:
- an array of all the Platform descriptions for the font
or
null
if there are none - Throws:
InvalidFontException
UnsupportedFontException
FontLoadingException
-
getPlatformFontDescription
PlatformFontDescription[] getPlatformFontDescription(Platform platform) throws InvalidFontException, UnsupportedFontException, FontLoadingException
Get all of the Platform descriptions for this font on the given platform.- Parameters:
platform
- the platform to get descriptions for- Returns:
- an array of all of the specified Platform descriptions for the font
or
null
if there are none - Throws:
InvalidFontException
UnsupportedFontException
FontLoadingException
-
getPlatformFontDescription
PlatformFontDescription[] getPlatformFontDescription(Platform platform, ULocale locale) throws InvalidFontException, UnsupportedFontException, FontLoadingException
Get all of the Platform descriptions for this font on the given platform and for the given locale.- Parameters:
platform
- the platform to get descriptions forlocale
- the locale to get descriptions for- Returns:
- an array of all of the specified Platform descriptions for the font
or
null
if there are none - Throws:
InvalidFontException
UnsupportedFontException
FontLoadingException
-
-