Package org.apache.fontbox.type1
Class Type1Lexer
java.lang.Object
org.apache.fontbox.type1.Type1Lexer
Lexer for the ASCII portions of an Adobe Type 1 font.
- See Also:
-
The PostScript language, of which Type 1 fonts are a subset, has a somewhat awkward lexical structure. It is neither regular nor context-free, and the execution of the program can modify the the behaviour of the lexer/parser. Nevertheless, this class represents an attempt to artificially separate the PostScript parsing process into separate lexing and parsing phases in order to reduce the complexity of the parsing phase.
- "PostScript Language Reference 3rd ed, Adobe Systems (1999)"
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Token
private final ByteBuffer
private static final org.apache.commons.logging.Log
Log instance.private int
-
Constructor Summary
ConstructorsConstructorDescriptionType1Lexer
(byte[] bytes) Constructs a new Type1Lexer given a header-less .pfb segment. -
Method Summary
Modifier and TypeMethodDescriptionprivate char
getChar()
Reads an ASCII char from the buffer.Returns the next token and consumes it.boolean
peekKind
(Token.Kind kind) Checks if the kind of the next token equals the given one without consuming it.Returns the next token without consuming it.private Token
readCharString
(int length) Reads a binary CharString.private String
Reads a line comment.private String
Reads a sequence of regular characters, i.e.private Token
Reads a (string).private Token
Reads a single token.private Token
Reads a number or returns null.
-
Field Details
-
LOG
private static final org.apache.commons.logging.Log LOGLog instance. -
buffer
-
aheadToken
-
openParens
private int openParens
-
-
Constructor Details
-
Type1Lexer
Type1Lexer(byte[] bytes) throws IOException Constructs a new Type1Lexer given a header-less .pfb segment.- Parameters:
bytes
- Header-less .pfb segment- Throws:
IOException
-
-
Method Details
-
nextToken
Returns the next token and consumes it.- Returns:
- The next token.
- Throws:
IOException
-
peekToken
Returns the next token without consuming it.- Returns:
- The next token
-
peekKind
Checks if the kind of the next token equals the given one without consuming it.- Returns:
- true if the kind of the next token equals the given one
-
getChar
Reads an ASCII char from the buffer.- Throws:
IOException
-
readToken
Reads a single token.- Parameters:
prevToken
- the previous token- Throws:
IOException
-
tryReadNumber
Reads a number or returns null.- Throws:
IOException
-
readRegular
Reads a sequence of regular characters, i.e. not delimiters or whitespace- Throws:
IOException
-
readComment
Reads a line comment.- Throws:
IOException
-
readString
Reads a (string).- Throws:
IOException
-
readCharString
Reads a binary CharString.- Throws:
IOException
-