Package org.apache.fop.render.java2d
Class CustomFontMetricsMapper
java.lang.Object
org.apache.fop.fonts.Typeface
org.apache.fop.render.java2d.CustomFontMetricsMapper
- All Implemented Interfaces:
Positionable
,Substitutable
,FontMetrics
,FontMetricsMapper
public class CustomFontMetricsMapper
extends Typeface
implements FontMetricsMapper, Substitutable, Positionable
FontMetricsMapper that delegates most methods to an underlying
FontMetrics
instance. This class was designed to allow
the underlying Font
to be loaded from a
user-configured file not registered in the current graphics environment.-
Field Summary
Fields inherited from class org.apache.fop.fonts.Typeface
eventListener, NOT_FOUND
-
Constructor Summary
ConstructorDescriptionCustomFontMetricsMapper
(CustomFont fontMetrics) Construction of this class results in the immediate construction of the underlyingFont
.CustomFontMetricsMapper
(LazyFont fontMetrics, InputStream fontSource) Construction of this class results in the immediate construction of the underlyingFont
. -
Method Summary
Modifier and TypeMethodDescriptionfinal int
getAscender
(int size) Returns the ascent of the font described by this FontMetrics object.getBoundingBox
(int glyphIndex, int size) Returns the bounding box of the glyph at the given index, for the given font size.final int
getCapHeight
(int size) Returns the size of a capital letter measured from the font's baseline.final int
getDescender
(int size) Returns the descent of the font described by this FontMetrics object.final String
Returns the font name for font embedding (may include a prefix, Example: "1E28bcArialMT").final String
Get the encoding of the font.Returns the font's family names as a Set of Strings (Example: "Helvetica").final Font
getFont
(int size) Gets aFont
instance of the font that thisFontMetrics
describes in the desired size.final String
Returns the "PostScript" font name (Example: "Helvetica-BoldOblique").final FontType
Returns the type of the font.final URI
Returns the URI of the font file from which these metrics were loaded.final String
Returns the font's full name (Example: "Helvetica Bold Oblique").final Map
Returns the kerning map for the font.int
getStrikeoutPosition
(int size) Returns the distance from the baseline to the center of the strikeout line (negative value indicates below baseline).int
getStrikeoutThickness
(int size) Returns the thickness of the strikeout line.int
getUnderlinePosition
(int size) Returns the distance from the baseline to the center of the underline (negative value indicates below baseline).int
getUnderlineThickness
(int size) Returns the thickness of the underline.final int
getWidth
(int i, int size) Return the width (in 1/1000ths of point size) of the character at code point i.final int[]
Return the array of widths.final int
getXHeight
(int size) Determines the typical font height of this FontMetrics objectfinal boolean
hasChar
(char c) Determines whether this font contains a particular character/glyph.final boolean
Indicates if the font has kerning information.boolean
Determines whether the font is a multibyte font.final char
mapChar
(char c) Map a Unicode character to a code point in the font.int[][]
performPositioning
(CharSequence cs, String script, String language) Perform glyph positioning using an implied font size.int[][]
performPositioning
(CharSequence cs, String script, String language, int fontSize) Perform glyph positioning.boolean
Determines if font performs glyph positioning.boolean
Determines if font performs glyph substitution.performSubstitution
(CharSequence cs, String script, String language, List associations, boolean retainControls) Perform substitutions on characters to effect glyph substitution.reorderCombiningMarks
(CharSequence cs, int[][] gpa, String script, String language, List associations) Reorder combining marks in character sequence so that they precede (within the sequence) the base character to which they are applied.Methods inherited from class org.apache.fop.fonts.Typeface
getMaxAscent, hadMappingOperations, hasFeature, isCID, notifyMapOperation, setEventListener, toString, warnMissingGlyph
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.fop.fonts.FontMetrics
getMaxAscent, hasFeature
-
Constructor Details
-
CustomFontMetricsMapper
Construction of this class results in the immediate construction of the underlyingFont
.- Parameters:
fontMetrics
- the metrics of the custom font- Throws:
FontFormatException
- if a bad font is loadedIOException
- if an I/O error occurs
-
CustomFontMetricsMapper
public CustomFontMetricsMapper(LazyFont fontMetrics, InputStream fontSource) throws FontFormatException, IOException Construction of this class results in the immediate construction of the underlyingFont
.- Parameters:
fontMetrics
- the fontfontSource
- the font source to access the font- Throws:
FontFormatException
- if a bad font is loadedIOException
- if an I/O error occurs
-
-
Method Details
-
getEncodingName
Get the encoding of the font.- Specified by:
getEncodingName
in classTypeface
- Returns:
- the encoding
-
hasChar
public final boolean hasChar(char c) Determines whether this font contains a particular character/glyph. -
mapChar
public final char mapChar(char c) Map a Unicode character to a code point in the font. -
getFont
Gets aFont
instance of the font that thisFontMetrics
describes in the desired size.- Specified by:
getFont
in interfaceFontMetricsMapper
- Parameters:
size
- font size- Returns:
- font with the desired characteristics.
-
getAscender
public final int getAscender(int size) Returns the ascent of the font described by this FontMetrics object. It returns the nominal ascent within the em box.- Specified by:
getAscender
in interfaceFontMetrics
- Parameters:
size
- font size- Returns:
- ascent in milliponts
-
getCapHeight
public final int getCapHeight(int size) Returns the size of a capital letter measured from the font's baseline.- Specified by:
getCapHeight
in interfaceFontMetrics
- Parameters:
size
- font size- Returns:
- height of capital characters
-
getDescender
public final int getDescender(int size) Returns the descent of the font described by this FontMetrics object.- Specified by:
getDescender
in interfaceFontMetrics
- Parameters:
size
- font size- Returns:
- descent in milliponts
-
getEmbedFontName
Returns the font name for font embedding (may include a prefix, Example: "1E28bcArialMT").- Specified by:
getEmbedFontName
in interfaceFontMetrics
- Returns:
- the name for font embedding
-
getFamilyNames
Returns the font's family names as a Set of Strings (Example: "Helvetica").- Specified by:
getFamilyNames
in interfaceFontMetrics
- Returns:
- the font's family names (a Set of Strings)
-
getFontName
Returns the "PostScript" font name (Example: "Helvetica-BoldOblique").- Specified by:
getFontName
in interfaceFontMetrics
- Returns:
- the font name
-
getFontURI
Returns the URI of the font file from which these metrics were loaded.- Specified by:
getFontURI
in interfaceFontMetrics
- Returns:
- the font file's URI
-
getFontType
Returns the type of the font.- Specified by:
getFontType
in interfaceFontMetrics
- Returns:
- the font type
-
getFullName
Returns the font's full name (Example: "Helvetica Bold Oblique").- Specified by:
getFullName
in interfaceFontMetrics
- Returns:
- the font's full name
-
getKerningInfo
Returns the kerning map for the font.- Specified by:
getKerningInfo
in interfaceFontMetrics
- Returns:
- the kerning map
-
getWidth
public final int getWidth(int i, int size) Return the width (in 1/1000ths of point size) of the character at code point i.- Specified by:
getWidth
in interfaceFontMetrics
- Parameters:
i
- code point indexsize
- font size- Returns:
- the width of the character
-
getWidths
public final int[] getWidths()Return the array of widths.This is used to get an array for inserting in an output format. It should not be used for lookup.
- Specified by:
getWidths
in interfaceFontMetrics
- Returns:
- an array of widths
-
getBoundingBox
Description copied from interface:FontMetrics
Returns the bounding box of the glyph at the given index, for the given font size.- Specified by:
getBoundingBox
in interfaceFontMetrics
- Parameters:
glyphIndex
- glyph indexsize
- font size- Returns:
- the scaled bounding box scaled in 1/1000ths of the given size
-
getXHeight
public final int getXHeight(int size) Determines the typical font height of this FontMetrics object- Specified by:
getXHeight
in interfaceFontMetrics
- Parameters:
size
- font size- Returns:
- font height in millipoints
-
getUnderlinePosition
public int getUnderlinePosition(int size) Description copied from interface:FontMetrics
Returns the distance from the baseline to the center of the underline (negative value indicates below baseline).- Specified by:
getUnderlinePosition
in interfaceFontMetrics
- Parameters:
size
- font size- Returns:
- the position in 1/1000ths of the font size
-
getUnderlineThickness
public int getUnderlineThickness(int size) Description copied from interface:FontMetrics
Returns the thickness of the underline.- Specified by:
getUnderlineThickness
in interfaceFontMetrics
- Parameters:
size
- font size- Returns:
- the thickness in 1/1000ths of the font size
-
getStrikeoutPosition
public int getStrikeoutPosition(int size) Description copied from interface:FontMetrics
Returns the distance from the baseline to the center of the strikeout line (negative value indicates below baseline).- Specified by:
getStrikeoutPosition
in interfaceFontMetrics
- Parameters:
size
- font size- Returns:
- the position in 1/1000ths of the font size
-
getStrikeoutThickness
public int getStrikeoutThickness(int size) Description copied from interface:FontMetrics
Returns the thickness of the strikeout line.- Specified by:
getStrikeoutThickness
in interfaceFontMetrics
- Parameters:
size
- font size- Returns:
- the thickness in 1/1000ths of the font size
-
hasKerningInfo
public final boolean hasKerningInfo()Indicates if the font has kerning information.- Specified by:
hasKerningInfo
in interfaceFontMetrics
- Returns:
- true if kerning is available.
-
isMultiByte
public boolean isMultiByte()Determines whether the font is a multibyte font.- Specified by:
isMultiByte
in interfaceFontMetrics
- Overrides:
isMultiByte
in classTypeface
- Returns:
- True if it is multibyte
-
performsPositioning
public boolean performsPositioning()Determines if font performs glyph positioning.- Specified by:
performsPositioning
in interfacePositionable
- Returns:
- true if performs positioning
-
performPositioning
Perform glyph positioning.- Specified by:
performPositioning
in interfacePositionable
- Parameters:
cs
- character sequence to map to position offsets (advancement adjustments)script
- a script identifierlanguage
- a language identifierfontSize
- font size- Returns:
- array (sequence) of 4-tuples of placement [PX,PY] and advance [AX,AY] adjustments, in that order, with one 4-tuple for each element of glyph sequence, or null if no non-zero adjustment applies
-
performPositioning
Perform glyph positioning using an implied font size.- Specified by:
performPositioning
in interfacePositionable
- Parameters:
cs
- character sequence to map to position offsets (advancement adjustments)script
- a script identifierlanguage
- a language identifier- Returns:
- array (sequence) of 4-tuples of placement [PX,PY] and advance [AX,AY] adjustments, in that order, with one 4-tuple for each element of glyph sequence, or null if no non-zero adjustment applies
-
performsSubstitution
public boolean performsSubstitution()Determines if font performs glyph substitution.- Specified by:
performsSubstitution
in interfaceSubstitutable
- Returns:
- true if performs substitution.
-
performSubstitution
public CharSequence performSubstitution(CharSequence cs, String script, String language, List associations, boolean retainControls) Perform substitutions on characters to effect glyph substitution. If some substitution is performed, it entails mapping from one or more input characters denoting textual character information to one or more output character codes denoting glyphs in this font, where the output character codes may make use of private character code values that have significance only for this font.- Specified by:
performSubstitution
in interfaceSubstitutable
- Parameters:
cs
- character sequence to map to output font encoding character sequencescript
- a script identifierlanguage
- a language identifierassociations
- optional list to receive list of character associationsretainControls
- if true, then retain control characters and their glyph mappings, otherwise remove- Returns:
- output sequence (represented as a character sequence, where each character in the returned sequence denotes "font characters", i.e., character codes that map directly (1-1) to their associated glyphs
-
reorderCombiningMarks
public CharSequence reorderCombiningMarks(CharSequence cs, int[][] gpa, String script, String language, List associations) Reorder combining marks in character sequence so that they precede (within the sequence) the base character to which they are applied. N.B. In the case of LTR segments, marks are not reordered by this, method since when the segment is reversed by BIDI processing, marks are automatically reordered to precede their base character.- Specified by:
reorderCombiningMarks
in interfaceSubstitutable
- Parameters:
cs
- character sequence within which combining marks to be reorderedgpa
- associated glyph position adjustments (also reordered)script
- a script identifierlanguage
- a language identifierassociations
- optional list of associations to be reordered- Returns:
- output sequence containing reordered "font characters"
-
getRealFont
-