Package org.apache.fontbox.cmap
Class CMapParser
java.lang.Object
org.apache.fontbox.cmap.CMapParser
Parses a CMap stream.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final classInternal class.private static final classInternal class. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance of CMapParser.CMapParser(boolean strictMode) Creates a new instance of CMapParser. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddMappingFrombfrange(CMap cmap, byte[] startCode, int values, byte[] tokenBytes) private voidaddMappingFrombfrange(CMap cmap, byte[] startCode, List<byte[]> tokenBytesList) private voidcheckExpectedOperator(CMapParser.Operator operator, String expectedOperatorName, String rangeName) Throws an IOException if expectedOperatorName not equals operator.opprivate static StringcreateStringFromBytes(byte[] bytes) private RandomAccessReadgetExternalCMap(String name) Returns a RandomAccessRead containing the given "use" CMap.private static booleanincrement(byte[] data, int position, boolean useStrictMode) private static booleanisDelimiter(int aByte) Is this a standard PDF delimiter character?private static booleanisWhitespaceOrEOF(int aByte) parse(RandomAccessRead randomAccessRead) This will parse the stream and create a cmap object.private voidparseBeginbfchar(Number cosCount, RandomAccessRead randomAccessRead, CMap result) private voidparseBeginbfrange(Number cosCount, RandomAccessRead randomAccessRead, CMap result) private voidparseBegincidchar(Number cosCount, RandomAccessRead randomAccessRead, CMap result) private voidparseBegincidrange(int numberOfLines, RandomAccessRead randomAccessRead, CMap result) private voidparseBegincodespacerange(Number cosCount, RandomAccessRead randomAccessRead, CMap result) private byte[]parseByteArray(RandomAccessRead randomAccessRead) private IntegerparseInteger(RandomAccessRead randomAccessRead) private voidparseLiteralName(CMapParser.LiteralName literal, RandomAccessRead randomAccessRead, CMap result) private ObjectparseNextToken(RandomAccessRead randomAccessRead) parsePredefined(String name) Parses a predefined CMap.private voidparseUsecmap(CMapParser.LiteralName useCmapName, CMap result) readArray(RandomAccessRead randomAccessRead) private ObjectreadDictionary(RandomAccessRead randomAccessRead) private StringreadLine(RandomAccessRead randomAccessRead, int firstByte) private CMapParser.LiteralNamereadLiteralName(RandomAccessRead randomAccessRead) private NumberreadNumber(RandomAccessRead randomAccessRead, int firstByte) private CMapParser.OperatorreadOperator(RandomAccessRead randomAccessRead, int firstByte) private StringreadString(RandomAccessRead randomAccessRead) private voidreadUntilEndOfLine(RandomAccessRead randomAccessRead, StringBuilder buf)
-
Field Details
-
MARK_END_OF_DICTIONARY
- See Also:
-
MARK_END_OF_ARRAY
- See Also:
-
tokenParserByteBuffer
private final byte[] tokenParserByteBuffer -
strictMode
private boolean strictMode
-
-
Constructor Details
-
CMapParser
public CMapParser()Creates a new instance of CMapParser. -
CMapParser
public CMapParser(boolean strictMode) Creates a new instance of CMapParser.- Parameters:
strictMode- activates the strict mode used for inline CMaps
-
-
Method Details
-
parsePredefined
Parses a predefined CMap.- Parameters:
name- CMap name.- Returns:
- The parsed predefined CMap as a java object, never null.
- Throws:
IOException- If the CMap could not be parsed.
-
parse
This will parse the stream and create a cmap object.- Parameters:
randomAccessRead- the source of the CMap to be parsed.- Returns:
- The parsed source as a java object, never null.
- Throws:
IOException- If there is an error parsing the data.
-
parseUsecmap
- Throws:
IOException
-
parseLiteralName
private void parseLiteralName(CMapParser.LiteralName literal, RandomAccessRead randomAccessRead, CMap result) throws IOException - Throws:
IOException
-
checkExpectedOperator
private void checkExpectedOperator(CMapParser.Operator operator, String expectedOperatorName, String rangeName) throws IOException Throws an IOException if expectedOperatorName not equals operator.op- Parameters:
operator- Instance of operatorexpectedOperatorName- Expected name of operatorrangeName- The name of the range in which the operator is expected (without a tilde character), to be used in the exception message.- Throws:
IOException- if expectedOperatorName not equals operator.op
-
parseBegincodespacerange
private void parseBegincodespacerange(Number cosCount, RandomAccessRead randomAccessRead, CMap result) throws IOException - Throws:
IOException
-
parseBeginbfchar
private void parseBeginbfchar(Number cosCount, RandomAccessRead randomAccessRead, CMap result) throws IOException - Throws:
IOException
-
parseBegincidrange
private void parseBegincidrange(int numberOfLines, RandomAccessRead randomAccessRead, CMap result) throws IOException - Throws:
IOException
-
parseBegincidchar
private void parseBegincidchar(Number cosCount, RandomAccessRead randomAccessRead, CMap result) throws IOException - Throws:
IOException
-
parseBeginbfrange
private void parseBeginbfrange(Number cosCount, RandomAccessRead randomAccessRead, CMap result) throws IOException - Throws:
IOException
-
addMappingFrombfrange
-
addMappingFrombfrange
-
getExternalCMap
Returns a RandomAccessRead containing the given "use" CMap.- Parameters:
name- Name of the given "use" CMap resource.- Throws:
IOException- if the CMap resource doesn't exist or if there is an error opening it.
-
parseNextToken
- Throws:
IOException
-
parseInteger
- Throws:
IOException
-
parseByteArray
- Throws:
IOException
-
readArray
- Throws:
IOException
-
readString
- Throws:
IOException
-
readLine
- Throws:
IOException
-
readLiteralName
private CMapParser.LiteralName readLiteralName(RandomAccessRead randomAccessRead) throws IOException - Throws:
IOException
-
readOperator
private CMapParser.Operator readOperator(RandomAccessRead randomAccessRead, int firstByte) throws IOException - Throws:
IOException
-
readNumber
- Throws:
IOException
-
readDictionary
- Throws:
IOException
-
readUntilEndOfLine
private void readUntilEndOfLine(RandomAccessRead randomAccessRead, StringBuilder buf) throws IOException - Throws:
IOException
-
isWhitespaceOrEOF
private static boolean isWhitespaceOrEOF(int aByte) -
isDelimiter
private static boolean isDelimiter(int aByte) Is this a standard PDF delimiter character? -
increment
private static boolean increment(byte[] data, int position, boolean useStrictMode) -
createStringFromBytes
-