public class AFMParser
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ASCENDER
This is ascender attribute.
|
private static int |
BITS_IN_HEX |
static java.lang.String |
CAP_HEIGHT
This is the cap height attribute.
|
static java.lang.String |
CC
This is a composite character.
|
static java.lang.String |
CHAR_WIDTH
This is the char width.
|
static java.lang.String |
CHARACTER_SET
This is the character set.
|
static java.lang.String |
CHARACTERS
This is the characters attribute.
|
static java.lang.String |
CHARMETRICS_B
The character metrics value.
|
static java.lang.String |
CHARMETRICS_C
The character metrics c value.
|
static java.lang.String |
CHARMETRICS_CH
The character metrics c value.
|
static java.lang.String |
CHARMETRICS_L
The character metrics value.
|
static java.lang.String |
CHARMETRICS_N
The character metrics value.
|
static java.lang.String |
CHARMETRICS_VV
The character metrics value.
|
static java.lang.String |
CHARMETRICS_W
The character metrics value.
|
static java.lang.String |
CHARMETRICS_W0
The character metrics value.
|
static java.lang.String |
CHARMETRICS_W0X
The character metrics value.
|
static java.lang.String |
CHARMETRICS_W0Y
The character metrics value.
|
static java.lang.String |
CHARMETRICS_W1
The character metrics value.
|
static java.lang.String |
CHARMETRICS_W1X
The character metrics value.
|
static java.lang.String |
CHARMETRICS_W1Y
The character metrics value.
|
static java.lang.String |
CHARMETRICS_WX
The character metrics value.
|
static java.lang.String |
CHARMETRICS_WY
The character metrics value.
|
static java.lang.String |
COMMENT
This is a comment in a AFM file.
|
static java.lang.String |
DESCENDER
This is the descender attribute.
|
static java.lang.String |
ENCODING_SCHEME
This is the encoding scheme.
|
static java.lang.String |
END_CHAR_METRICS
This is the end of character metrics.
|
static java.lang.String |
END_COMPOSITES
This is the end compisites data section.
|
static java.lang.String |
END_FONT_METRICS
This is the constant used in the AFM file to end a font metrics item.
|
static java.lang.String |
END_KERN_DATA
This is the end of kern data.
|
static java.lang.String |
END_KERN_PAIRS
This is the end of kern pairs data.
|
static java.lang.String |
END_TRACK_KERN
This is the end of track kern data.
|
static java.lang.String |
ESC_CHAR
This is the escape character.
|
static java.lang.String |
FAMILY_NAME
This is the Family name.
|
static java.lang.String |
FONT_BBOX
This is the font bounding box.
|
static java.lang.String |
FONT_NAME
This is the font name.
|
static java.lang.String |
FULL_NAME
This is the full name.
|
private java.io.InputStream |
input |
static java.lang.String |
IS_BASE_FONT
This will determine if this is a base font.
|
static java.lang.String |
IS_FIXED_PITCH
This will determine if this is fixed pitch.
|
static java.lang.String |
IS_FIXED_V
This will tell if the V is fixed.
|
static java.lang.String |
ITALIC_ANGLE
This is the italic angle.
|
static java.lang.String |
KERN_PAIR_KP
This is a kern pair.
|
static java.lang.String |
KERN_PAIR_KPH
This is a kern pair.
|
static java.lang.String |
KERN_PAIR_KPX
This is a kern pair.
|
static java.lang.String |
KERN_PAIR_KPY
This is a kern pair.
|
static java.lang.String |
MAPPING_SCHEME
This is the mapping scheme.
|
static java.lang.String |
NOTICE
This is the notice.
|
static java.lang.String |
PCC
This is a composite character part.
|
static java.lang.String |
START_CHAR_METRICS
This is the start of character metrics.
|
static java.lang.String |
START_COMPOSITES
This is the start compisites data section.
|
static java.lang.String |
START_FONT_METRICS
This is the constant used in the AFM file to start a font metrics item.
|
static java.lang.String |
START_KERN_DATA
This is the start of kern data.
|
static java.lang.String |
START_KERN_PAIRS
This is the start of kern pairs data.
|
static java.lang.String |
START_KERN_PAIRS0
This is the start of kern pairs data.
|
static java.lang.String |
START_KERN_PAIRS1
This is the start of kern pairs data.
|
static java.lang.String |
START_TRACK_KERN
This is the start of track kern data.
|
static java.lang.String |
STD_HW
The character metrics value.
|
static java.lang.String |
STD_VW
The character metrics value.
|
static java.lang.String |
UNDERLINE_POSITION
The underline position.
|
static java.lang.String |
UNDERLINE_THICKNESS
This is the Underline thickness.
|
static java.lang.String |
V_VECTOR
This is the V Vector attribute.
|
static java.lang.String |
VERSION
This is the version of the font.
|
static java.lang.String |
WEIGHT
This is the weight.
|
static java.lang.String |
X_HEIGHT
This is the X height.
|
Constructor and Description |
---|
AFMParser(java.io.InputStream in)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
private java.lang.String |
hexToString(java.lang.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.
|
FontMetrics |
parse()
This will parse the AFM document.
|
FontMetrics |
parse(boolean reducedDataset)
This will parse the AFM document.
|
private CharMetric |
parseCharMetric()
This will parse a single CharMetric object from the stream.
|
private Composite |
parseComposite()
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 |
parseKernPair()
This will parse a kern pair from the data stream.
|
private boolean |
readBoolean()
This will read a boolean from the stream.
|
private float |
readFloat()
This will read a float from the stream.
|
private int |
readInt()
This will read an integer from the stream.
|
private java.lang.String |
readLine()
This will read until the end of a line.
|
private java.lang.String |
readString()
This will read a string from the input stream and stop at any whitespace.
|
private void |
verifySemicolon(java.util.StringTokenizer tokenizer)
This is used to verify that a semicolon is the next token in the stream.
|
public static final java.lang.String COMMENT
public static final java.lang.String START_FONT_METRICS
public static final java.lang.String END_FONT_METRICS
public static final java.lang.String FONT_NAME
public static final java.lang.String FULL_NAME
public static final java.lang.String FAMILY_NAME
public static final java.lang.String WEIGHT
public static final java.lang.String FONT_BBOX
public static final java.lang.String VERSION
public static final java.lang.String NOTICE
public static final java.lang.String ENCODING_SCHEME
public static final java.lang.String MAPPING_SCHEME
public static final java.lang.String ESC_CHAR
public static final java.lang.String CHARACTER_SET
public static final java.lang.String CHARACTERS
public static final java.lang.String IS_BASE_FONT
public static final java.lang.String V_VECTOR
public static final java.lang.String IS_FIXED_V
public static final java.lang.String CAP_HEIGHT
public static final java.lang.String X_HEIGHT
public static final java.lang.String ASCENDER
public static final java.lang.String DESCENDER
public static final java.lang.String UNDERLINE_POSITION
public static final java.lang.String UNDERLINE_THICKNESS
public static final java.lang.String ITALIC_ANGLE
public static final java.lang.String CHAR_WIDTH
public static final java.lang.String IS_FIXED_PITCH
public static final java.lang.String START_CHAR_METRICS
public static final java.lang.String END_CHAR_METRICS
public static final java.lang.String CHARMETRICS_C
public static final java.lang.String CHARMETRICS_CH
public static final java.lang.String CHARMETRICS_WX
public static final java.lang.String CHARMETRICS_W0X
public static final java.lang.String CHARMETRICS_W1X
public static final java.lang.String CHARMETRICS_WY
public static final java.lang.String CHARMETRICS_W0Y
public static final java.lang.String CHARMETRICS_W1Y
public static final java.lang.String CHARMETRICS_W
public static final java.lang.String CHARMETRICS_W0
public static final java.lang.String CHARMETRICS_W1
public static final java.lang.String CHARMETRICS_VV
public static final java.lang.String CHARMETRICS_N
public static final java.lang.String CHARMETRICS_B
public static final java.lang.String CHARMETRICS_L
public static final java.lang.String STD_HW
public static final java.lang.String STD_VW
public static final java.lang.String START_TRACK_KERN
public static final java.lang.String END_TRACK_KERN
public static final java.lang.String START_KERN_DATA
public static final java.lang.String END_KERN_DATA
public static final java.lang.String START_KERN_PAIRS
public static final java.lang.String END_KERN_PAIRS
public static final java.lang.String START_KERN_PAIRS0
public static final java.lang.String START_KERN_PAIRS1
public static final java.lang.String START_COMPOSITES
public static final java.lang.String END_COMPOSITES
public static final java.lang.String CC
public static final java.lang.String PCC
public static final java.lang.String KERN_PAIR_KP
public static final java.lang.String KERN_PAIR_KPH
public static final java.lang.String KERN_PAIR_KPX
public static final java.lang.String KERN_PAIR_KPY
private static final int BITS_IN_HEX
private final java.io.InputStream input
public AFMParser(java.io.InputStream in)
in
- The input stream to read the AFM document from.public FontMetrics parse() throws java.io.IOException
java.io.IOException
- If there is an IO error reading the document.public FontMetrics parse(boolean reducedDataset) throws java.io.IOException
reducedDataset
- parse a reduced subset of data if set to truejava.io.IOException
- If there is an IO error reading the document.private FontMetrics parseFontMetric(boolean reducedDataset) throws java.io.IOException
java.io.IOException
- If there is an error reading the AFM file.private void parseKernData(FontMetrics fontMetrics) throws java.io.IOException
fontMetrics
- The metrics class to put the parsed data into.java.io.IOException
- If there is an error parsing the data.private KernPair parseKernPair() throws java.io.IOException
java.io.IOException
- If there is an error reading from the stream.private java.lang.String hexToString(java.lang.String hexString) throws java.io.IOException
hexString
- An angle bracket string.java.io.IOException
- If the string is in an invalid format.private Composite parseComposite() throws java.io.IOException
java.io.IOException
- If there is an error parsing the composite.private CharMetric parseCharMetric() throws java.io.IOException
java.io.IOException
- If there is an error reading from the stream.private void verifySemicolon(java.util.StringTokenizer tokenizer) throws java.io.IOException
tokenizer
- The tokenizer to read from.java.io.IOException
- If the semicolon is missing.private boolean readBoolean() throws java.io.IOException
java.io.IOException
private int readInt() throws java.io.IOException
java.io.IOException
private float readFloat() throws java.io.IOException
java.io.IOException
private java.lang.String readLine() throws java.io.IOException
java.io.IOException
private java.lang.String readString() throws java.io.IOException
java.io.IOException
- If an IO error occurs when reading from the stream.private boolean isEOL(int character)
character
- The character to test for whitespace.private boolean isWhitespace(int character)
character
- The character to test for whitespace.