Package org.apache.fop.afp.fonts
Class RasterFont
- java.lang.Object
-
- org.apache.fop.fonts.Typeface
-
- org.apache.fop.afp.fonts.AFPFont
-
- org.apache.fop.afp.fonts.RasterFont
-
- All Implemented Interfaces:
FontMetrics
public class RasterFont extends AFPFont
A font where each character is stored as an array of pixels (a bitmap). Such fonts are not easily scalable, in contrast to vectored fonts. With this type of font, the font metrics information is held in character set files (one for each size and style).
-
-
Field Summary
Fields Modifier and Type Field Description private CharacterSet
charSet
private java.util.SortedMap<java.lang.Integer,CharacterSet>
charSets
protected static org.apache.commons.logging.Log
LOG
Static logging instanceprivate java.util.Map<java.lang.Integer,CharacterSet>
substitutionCharSets
-
Fields inherited from class org.apache.fop.fonts.Typeface
eventListener, NOT_FOUND
-
-
Constructor Summary
Constructors Constructor Description RasterFont(java.lang.String name, boolean embeddable)
Constructor for the raster font requires the name, weight and style attribute to be available as this forms the key to the font.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addCharacterSet(int size, CharacterSet characterSet)
Adds the character set for the given point sizeint
getAscender(int size)
The ascender is the part of a lowercase letter that extends above the "x-height" (the height of the letter "x"), such as "d", "t", or "h".java.awt.Rectangle
getBoundingBox(int character, int size)
TODOint
getCapHeight(int size)
Obtains the height of capital letters for the specified point size.CharacterSet
getCharacterSet(int sizeInMpt)
Get the character set metrics for the specified point size.int
getDescender(int size)
The descender is the part of a lowercase letter that extends below the base line, such as "g", "j", or "p".java.lang.String
getEncodingName()
Get the encoding of the font.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.int
getWidth(int character, int size)
Obtain the width of the character for the specified point size.int
getXHeight(int size)
The "x-height" (the height of the letter "x").boolean
hasChar(char c)
Determines whether this font contains a particular character/glyph.char
mapChar(char c)
Map a Unicode character to a code point in the font.private int
metricsToAbsoluteSize(CharacterSet cs, double value, int givenSize)
private int
metricsToAbsoluteSize(CharacterSet cs, int value, int givenSize)
-
Methods inherited from class org.apache.fop.afp.fonts.AFPFont
getEmbedFontName, getFamilyNames, getFontName, getFontType, getFontURI, getFullName, getKerningInfo, getStrikeoutPosition, getStrikeoutThickness, getWidths, hasKerningInfo, isEmbeddable, toString, toUnicodeCodepoint
-
Methods inherited from class org.apache.fop.fonts.Typeface
getMaxAscent, hadMappingOperations, hasFeature, isCID, isMultiByte, notifyMapOperation, setEventListener, warnMissingGlyph
-
-
-
-
Field Detail
-
LOG
protected static final org.apache.commons.logging.Log LOG
Static logging instance
-
charSets
private final java.util.SortedMap<java.lang.Integer,CharacterSet> charSets
-
substitutionCharSets
private java.util.Map<java.lang.Integer,CharacterSet> substitutionCharSets
-
charSet
private CharacterSet charSet
-
-
Constructor Detail
-
RasterFont
public RasterFont(java.lang.String name, boolean embeddable)
Constructor for the raster font requires the name, weight and style attribute to be available as this forms the key to the font.- Parameters:
name
- the name of the fontembeddable
-true
if the font is embeddable
-
-
Method Detail
-
addCharacterSet
public void addCharacterSet(int size, CharacterSet characterSet)
Adds the character set for the given point size- Parameters:
size
- point size (in mpt)characterSet
- character set
-
getCharacterSet
public CharacterSet getCharacterSet(int sizeInMpt)
Get the character set metrics for the specified point size.- Specified by:
getCharacterSet
in classAFPFont
- Parameters:
sizeInMpt
- the point size (in mpt)- Returns:
- the character set metrics
-
metricsToAbsoluteSize
private int metricsToAbsoluteSize(CharacterSet cs, int value, int givenSize)
-
metricsToAbsoluteSize
private int metricsToAbsoluteSize(CharacterSet cs, double value, int givenSize)
-
getAscender
public int getAscender(int size)
The ascender is the part of a lowercase letter that extends above the "x-height" (the height of the letter "x"), such as "d", "t", or "h". Also used to denote the part of the letter extending above the x-height.- Parameters:
size
- the font size (in mpt)- Returns:
- the ascender for the given point size
-
getUnderlinePosition
public int getUnderlinePosition(int size)
Returns the distance from the baseline to the center of the underline (negative value indicates below baseline).- Parameters:
size
- font size- Returns:
- the position in 1/1000ths of the font size
-
getUnderlineThickness
public int getUnderlineThickness(int size)
Description copied from class:AFPFont
Returns the thickness of the underline.- Specified by:
getUnderlineThickness
in interfaceFontMetrics
- Overrides:
getUnderlineThickness
in classAFPFont
- Parameters:
size
- font size- Returns:
- the thickness in 1/1000ths of the font size
-
getCapHeight
public int getCapHeight(int size)
Obtains the height of capital letters for the specified point size.- Parameters:
size
- the font size (in mpt)- Returns:
- the cap height for the specified point size
-
getDescender
public int getDescender(int size)
The descender is the part of a lowercase letter that extends below the base line, such as "g", "j", or "p". Also used to denote the part of the letter extending below the base line.- Parameters:
size
- the font size (in mpt)- Returns:
- the descender for the specified point size
-
getXHeight
public int getXHeight(int size)
The "x-height" (the height of the letter "x").- Parameters:
size
- the font size (in mpt)- Returns:
- the x height for the given point size
-
getWidth
public int getWidth(int character, int size)
Obtain the width of the character for the specified point size.- Parameters:
character
- the charactersize
- the font size (in mpt)- Returns:
- the width for the given point size
-
getBoundingBox
public java.awt.Rectangle getBoundingBox(int character, int size)
TODO- Specified by:
getBoundingBox
in interfaceFontMetrics
- Specified by:
getBoundingBox
in classAFPFont
- Parameters:
character
- glyph indexsize
- font size- Returns:
- the scaled bounding box scaled in 1/1000ths of the given size
-
hasChar
public boolean hasChar(char c)
Determines whether this font contains a particular character/glyph.
-
mapChar
public char mapChar(char c)
Map a Unicode character to a code point in the font.
-
getEncodingName
public java.lang.String getEncodingName()
Get the encoding of the font.- Specified by:
getEncodingName
in classTypeface
- Returns:
- the encoding
-
-