Top Description Fields Constructors Methods
org.apache.fontbox.type1

pack-priv Class Type1Lexer

extends Object
Class Inheritance
Imports
java.io.IOException, java.nio.BufferUnderflowException, .ByteBuffer, org.apache.commons.logging.Log, .LogFactory

Lexer for the ASCII portions of an Adobe Type 1 font.
Author
John Hewson
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

Modifier and TypeField and Description
private Token
private final ByteBuffer
private static final Log
LOG

Log instance.

private int

Constructor Summary

AccessConstructor and Description
pack-priv
Type1Lexer(byte[]
Header-less .pfb segment
bytes
)

Constructs a new Type1Lexer given a header-less .pfb segment.

Method Summary

Modifier and TypeMethod and Description
private char
getChar()

Reads an ASCII char from the buffer.

public Token

Returns:

The next token.
nextToken
()

Returns the next token and consumes it.

public boolean

Returns:

true if the kind of the next token equals the given one
peekKind
(Token.Kind kind)

Checks if the kind of the next token equals the given one without consuming it.

public Token

Returns:

The next token
peekToken
()

Returns the next token without consuming it.

private Token
readCharString(int length)

Reads a binary CharString.

private String
readComment()

Reads a line comment.

private String
readRegular()

Reads a sequence of regular characters, i.e. not delimiters or whitespace

private Token
readString()

Reads a (string).

private Token
readToken(Token
the previous token
prevToken
)

Reads a single token.

private Token
tryReadNumber()

Reads a number or returns null.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

aheadTokenback to summary
private Token aheadToken
bufferback to summary
private final ByteBuffer buffer
LOGback to summary
private static final Log LOG

Log instance.

openParensback to summary
private int openParens

Constructor Detail

Type1Lexerback to summary
pack-priv Type1Lexer(byte[] bytes) throws IOException

Constructs a new Type1Lexer given a header-less .pfb segment.

Parameters
bytes:byte[]

Header-less .pfb segment

Method Detail

getCharback to summary
private char getChar() throws IOException

Reads an ASCII char from the buffer.

nextTokenback to summary
public Token nextToken() throws IOException

Returns the next token and consumes it.

Returns:Token

The next token.

peekKindback to summary
public boolean peekKind(Token.Kind kind)

Checks if the kind of the next token equals the given one without consuming it.

Returns:boolean

true if the kind of the next token equals the given one

peekTokenback to summary
public Token peekToken()

Returns the next token without consuming it.

Returns:Token

The next token

readCharStringback to summary
private Token readCharString(int length) throws IOException

Reads a binary CharString.

readCommentback to summary
private String readComment() throws IOException

Reads a line comment.

readRegularback to summary
private String readRegular() throws IOException

Reads a sequence of regular characters, i.e. not delimiters or whitespace

readStringback to summary
private Token readString() throws IOException

Reads a (string).

readTokenback to summary
private Token readToken(Token prevToken) throws IOException

Reads a single token.

Parameters
prevToken:Token

the previous token

tryReadNumberback to summary
private Token tryReadNumber() throws IOException

Reads a number or returns null.