Package org.apache.fontbox.afm
Class AFMParser
java.lang.Object
org.apache.fontbox.afm.AFMParser
This class is used to parse AFM(Adobe Font Metrics) documents.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
This is ascender attribute.private static final int
static final String
This is the cap height attribute.static final String
This is a composite character.static final String
This is the char width.static final String
This is the character set.static final String
This is the characters attribute.static final String
The character metrics value.static final String
The character metrics c value.static final String
The character metrics c value.static final String
The character metrics value.static final String
The character metrics value.static final String
The character metrics value.static final String
The character metrics value.static final String
The character metrics value.static final String
The character metrics value.static final String
The character metrics value.static final String
The character metrics value.static final String
The character metrics value.static final String
The character metrics value.static final String
The character metrics value.static final String
The character metrics value.static final String
This is a comment in a AFM file.static final String
This is the descender attribute.static final String
This is the encoding scheme.static final String
This is the end of character metrics.static final String
This is the end composites data section.static final String
This is the constant used in the AFM file to end a font metrics item.static final String
This is the end of kern data.static final String
This is the end of kern pairs data.static final String
This is the end of track kern data.static final String
This is the escape character.static final String
This is the Family name.static final String
This is the font bounding box.static final String
This is the font name.static final String
This is the full name.private final InputStream
static final String
This will determine if this is a base font.static final String
This will determine if this is fixed pitch.static final String
This will tell if the V is fixed.static final String
This is the italic angle.static final String
This is a kern pair.static final String
This is a kern pair.static final String
This is a kern pair.static final String
This is a kern pair.static final String
This is the mapping scheme.static final String
This is the notice.static final String
This is a composite character part.static final String
This is the start of character metrics.static final String
This is the start composites data section.static final String
This is the constant used in the AFM file to start a font metrics item.static final String
This is the start of kern data.static final String
This is the start of kern pairs data.static final String
This is the start of kern pairs data.static final String
This is the start of kern pairs data.static final String
This is the start of track kern data.static final String
The character metrics value.static final String
The character metrics value.static final String
The underline position.static final String
This is the Underline thickness.static final String
This is the V Vector attribute.static final String
This is the version of the font.static final String
This is the weight.static final String
This is the X height. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate String
hexToString
(String hexString) This will convert and angle bracket hex string to a string.private boolean
isEOL
(int character) This will determine if the byte is a whitespace character or not.private boolean
isWhitespace
(int character) This will determine if the byte is a whitespace character or not.parse()
This will parse the AFM document.parse
(boolean reducedDataset) This will parse the AFM document.private CharMetric
This will parse a single CharMetric object from the stream.private Composite
This will parse a composite part from the stream.private FontMetrics
parseFontMetric
(boolean reducedDataset) This will parse a font metrics item.private void
parseKernData
(FontMetrics fontMetrics) This will parse the kern data.private KernPair
This will parse a kern pair from the data stream.private boolean
This will read a boolean from the stream.private float
This will read a float from the stream.private int
readInt()
This will read an integer from the stream.private String
readLine()
This will read until the end of a line.private String
This will read a string from the input stream and stop at any whitespace.private void
verifySemicolon
(StringTokenizer tokenizer) This is used to verify that a semicolon is the next token in the stream.
-
Field Details
-
COMMENT
This is a comment in a AFM file.- See Also:
-
START_FONT_METRICS
This is the constant used in the AFM file to start a font metrics item.- See Also:
-
END_FONT_METRICS
This is the constant used in the AFM file to end a font metrics item.- See Also:
-
FONT_NAME
This is the font name.- See Also:
-
FULL_NAME
This is the full name.- See Also:
-
FAMILY_NAME
This is the Family name.- See Also:
-
WEIGHT
This is the weight.- See Also:
-
FONT_BBOX
This is the font bounding box.- See Also:
-
VERSION
This is the version of the font.- See Also:
-
NOTICE
This is the notice.- See Also:
-
ENCODING_SCHEME
This is the encoding scheme.- See Also:
-
MAPPING_SCHEME
This is the mapping scheme.- See Also:
-
ESC_CHAR
This is the escape character.- See Also:
-
CHARACTER_SET
This is the character set.- See Also:
-
CHARACTERS
This is the characters attribute.- See Also:
-
IS_BASE_FONT
This will determine if this is a base font.- See Also:
-
V_VECTOR
This is the V Vector attribute.- See Also:
-
IS_FIXED_V
This will tell if the V is fixed.- See Also:
-
CAP_HEIGHT
This is the cap height attribute.- See Also:
-
X_HEIGHT
This is the X height.- See Also:
-
ASCENDER
This is ascender attribute.- See Also:
-
DESCENDER
This is the descender attribute.- See Also:
-
UNDERLINE_POSITION
The underline position.- See Also:
-
UNDERLINE_THICKNESS
This is the Underline thickness.- See Also:
-
ITALIC_ANGLE
This is the italic angle.- See Also:
-
CHAR_WIDTH
This is the char width.- See Also:
-
IS_FIXED_PITCH
This will determine if this is fixed pitch.- See Also:
-
START_CHAR_METRICS
This is the start of character metrics.- See Also:
-
END_CHAR_METRICS
This is the end of character metrics.- See Also:
-
CHARMETRICS_C
The character metrics c value.- See Also:
-
CHARMETRICS_CH
The character metrics c value.- See Also:
-
CHARMETRICS_WX
The character metrics value.- See Also:
-
CHARMETRICS_W0X
The character metrics value.- See Also:
-
CHARMETRICS_W1X
The character metrics value.- See Also:
-
CHARMETRICS_WY
The character metrics value.- See Also:
-
CHARMETRICS_W0Y
The character metrics value.- See Also:
-
CHARMETRICS_W1Y
The character metrics value.- See Also:
-
CHARMETRICS_W
The character metrics value.- See Also:
-
CHARMETRICS_W0
The character metrics value.- See Also:
-
CHARMETRICS_W1
The character metrics value.- See Also:
-
CHARMETRICS_VV
The character metrics value.- See Also:
-
CHARMETRICS_N
The character metrics value.- See Also:
-
CHARMETRICS_B
The character metrics value.- See Also:
-
CHARMETRICS_L
The character metrics value.- See Also:
-
STD_HW
The character metrics value.- See Also:
-
STD_VW
The character metrics value.- See Also:
-
START_TRACK_KERN
This is the start of track kern data.- See Also:
-
END_TRACK_KERN
This is the end of track kern data.- See Also:
-
START_KERN_DATA
This is the start of kern data.- See Also:
-
END_KERN_DATA
This is the end of kern data.- See Also:
-
START_KERN_PAIRS
This is the start of kern pairs data.- See Also:
-
END_KERN_PAIRS
This is the end of kern pairs data.- See Also:
-
START_KERN_PAIRS0
This is the start of kern pairs data.- See Also:
-
START_KERN_PAIRS1
This is the start of kern pairs data.- See Also:
-
START_COMPOSITES
This is the start composites data section.- See Also:
-
END_COMPOSITES
This is the end composites data section.- See Also:
-
CC
This is a composite character.- See Also:
-
PCC
This is a composite character part.- See Also:
-
KERN_PAIR_KP
This is a kern pair.- See Also:
-
KERN_PAIR_KPH
This is a kern pair.- See Also:
-
KERN_PAIR_KPX
This is a kern pair.- See Also:
-
KERN_PAIR_KPY
This is a kern pair.- See Also:
-
BITS_IN_HEX
private static final int BITS_IN_HEX- See Also:
-
input
-
-
Constructor Details
-
AFMParser
Constructor.- Parameters:
in
- The input stream to read the AFM document from.
-
-
Method Details
-
parse
This will parse the AFM document. The input stream is closed when the parsing is finished.- Returns:
- the parsed FontMetric
- Throws:
IOException
- If there is an IO error reading the document.
-
parse
This will parse the AFM document. The input stream is closed when the parsing is finished.- Parameters:
reducedDataset
- parse a reduced subset of data if set to true- Returns:
- the parsed FontMetric
- Throws:
IOException
- If there is an IO error reading the document.
-
parseFontMetric
This will parse a font metrics item.- Returns:
- The parse font metrics item.
- Throws:
IOException
- If there is an error reading the AFM file.
-
parseKernData
This will parse the kern data.- Parameters:
fontMetrics
- The metrics class to put the parsed data into.- Throws:
IOException
- If there is an error parsing the data.
-
parseKernPair
This will parse a kern pair from the data stream.- Returns:
- The kern pair that was parsed from the stream.
- Throws:
IOException
- If there is an error reading from the stream.
-
hexToString
This will convert and angle bracket hex string to a string.- Parameters:
hexString
- An angle bracket string.- Returns:
- The bytes of the hex string.
- Throws:
IOException
- If the string is in an invalid format.
-
parseComposite
This will parse a composite part from the stream.- Returns:
- The composite.
- Throws:
IOException
- If there is an error parsing the composite.
-
parseCharMetric
This will parse a single CharMetric object from the stream.- Returns:
- The next char metric in the stream.
- Throws:
IOException
- If there is an error reading from the stream.
-
verifySemicolon
This is used to verify that a semicolon is the next token in the stream.- Parameters:
tokenizer
- The tokenizer to read from.- Throws:
IOException
- If the semicolon is missing.
-
readBoolean
This will read a boolean from the stream.- Returns:
- The boolean in the stream.
- Throws:
IOException
-
readInt
This will read an integer from the stream.- Returns:
- The integer in the stream.
- Throws:
IOException
-
readFloat
This will read a float from the stream.- Returns:
- The float in the stream.
- Throws:
IOException
-
readLine
This will read until the end of a line.- Returns:
- The string that is read.
- Throws:
IOException
-
readString
This will read a string from the input stream and stop at any whitespace.- Returns:
- The string read from the stream.
- Throws:
IOException
- If an IO error occurs when reading from the stream.
-
isEOL
private boolean isEOL(int character) This will determine if the byte is a whitespace character or not.- Parameters:
character
- The character to test for whitespace.- Returns:
- true If the character is whitespace as defined by the AFM spec.
-
isWhitespace
private boolean isWhitespace(int character) This will determine if the byte is a whitespace character or not.- Parameters:
character
- The character to test for whitespace.- Returns:
- true If the character is whitespace as defined by the AFM spec.
-