Package org.apache.fontbox.type1
Class Type1Lexer
- java.lang.Object
-
- org.apache.fontbox.type1.Type1Lexer
-
class Type1Lexer extends java.lang.Object
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
Fields Modifier and Type Field Description private Token
aheadToken
private java.nio.ByteBuffer
buffer
private static org.apache.commons.logging.Log
LOG
Log instance.private int
openParens
-
Constructor Summary
Constructors Constructor Description Type1Lexer(byte[] bytes)
Constructs a new Type1Lexer given a header-less .pfb segment.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private char
getChar()
Reads an ASCII char from the buffer.Token
nextToken()
Returns the next token and consumes it.Token
peekToken()
Returns the next token without consuming it.private Token
readCharString(int length)
Reads a binary CharString.private java.lang.String
readComment()
Reads a line comment.private java.lang.String
readRegular()
Reads a sequence of regular characters, i.e.private Token
readString()
Reads a (string).private Token
readToken(Token prevToken)
Reads a single token.private Token
tryReadNumber()
Reads a number or returns null.
-
-
-
Field Detail
-
LOG
private static final org.apache.commons.logging.Log LOG
Log instance.
-
buffer
private final java.nio.ByteBuffer buffer
-
aheadToken
private Token aheadToken
-
openParens
private int openParens
-
-
Method Detail
-
nextToken
public Token nextToken() throws java.io.IOException
Returns the next token and consumes it.- Returns:
- The next token.
- Throws:
java.io.IOException
-
peekToken
public Token peekToken()
Returns the next token without consuming it.- Returns:
- The next token
-
getChar
private char getChar()
Reads an ASCII char from the buffer.
-
readToken
private Token readToken(Token prevToken) throws java.io.IOException
Reads a single token.- Parameters:
prevToken
- the previous token- Throws:
java.io.IOException
-
tryReadNumber
private Token tryReadNumber()
Reads a number or returns null.
-
readRegular
private java.lang.String readRegular()
Reads a sequence of regular characters, i.e. not delimiters or whitespace
-
readComment
private java.lang.String readComment()
Reads a line comment.
-
readString
private Token readString() throws java.io.IOException
Reads a (string).- Throws:
java.io.IOException
-
readCharString
private Token readCharString(int length)
Reads a binary CharString.
-
-