Package org.verapdf.pd.font.type1
Class BaseCharStringParser
java.lang.Object
org.verapdf.pd.font.type1.BaseCharStringParser
- Direct Known Subclasses:
Type1CharStringParser
This is base class for Type1CharStringParser and Type2CharStringParser.
- Author:
- Sergey Shemyakov
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBaseCharStringParser(ASInputStream stream) Constructor that calls method parse(), so width is extracted right after object is created.protectedBaseCharStringParser(ASInputStream stream, Map<Integer, CFFNumber> subrWidths) protectedBaseCharStringParser(ASInputStream stream, CFFIndex localSubrs, int bias, CFFIndex globalSubrs, int gBias) Constructor that calls method parse(), so width is extracted right after object is created.protectedBaseCharStringParser(ASInputStream stream, CFFIndex localSubrs, int bias, CFFIndex globalSubrs, int gBias, Map<Integer, CFFNumber> subrWidths) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidgetWidth()protected voidpopStack(int num) Pops several operands from Type 1 Build Char stack.protected abstract booleanprocessNextOperator(int nextByte) This method processes charstring-encoded operators.protected abstract CFFNumberreadNextNumber(int firstByte) This method reads next bytes from stream and interprets them as one number.protected intreadStreams(byte[] buffer, int size) protected void
-
Field Details
-
stack
-
globalSubrs
-
localSubrs
-
bias
protected int bias -
gBias
protected int gBias -
subrWidths
-
-
Constructor Details
-
BaseCharStringParser
Constructor that calls method parse(), so width is extracted right after object is created. Subroutines are ignored in this case.- Parameters:
stream- is stream with decoded CharString.- Throws:
IOException- if parsing fails.
-
BaseCharStringParser
protected BaseCharStringParser(ASInputStream stream, Map<Integer, CFFNumber> subrWidths) throws IOException- Throws:
IOException
-
BaseCharStringParser
protected BaseCharStringParser(ASInputStream stream, CFFIndex localSubrs, int bias, CFFIndex globalSubrs, int gBias) throws IOException Constructor that calls method parse(), so width is extracted right after object is created.- Parameters:
stream- is stream with decoded CharString.localSubrs- is local subroutines for this CharString.bias- is bias value for local subroutines as it is described in The Compact Font Format specification.gBias- is bias value for global subroutines as it is described in The Compact Font Format specification.- Throws:
IOException- if parsing fails.
-
BaseCharStringParser
protected BaseCharStringParser(ASInputStream stream, CFFIndex localSubrs, int bias, CFFIndex globalSubrs, int gBias, Map<Integer, CFFNumber> subrWidths) throws IOException- Throws:
IOException
-
-
Method Details
-
getWidth
- Returns:
- width of glyph or null if it can't be found in given CharString.
-
setWidth
-
readStreams
- Throws:
IOException
-
addStream
-
popStack
protected void popStack(int num) Pops several operands from Type 1 Build Char stack.- Parameters:
num- is amount of numbers to be popped.- Throws:
IOException- if stream reading error occurs.
-
processNextOperator
This method processes charstring-encoded operators. It should set width when it can be determined. Methods returns true if width is calculated.- Parameters:
nextByte- is first byte of operator. Note that this byte is already read.- Returns:
- true if width was extracted from processed operator.
- Throws:
IOException- if stream reading error occurs.
-
readNextNumber
This method reads next bytes from stream and interprets them as one number. In Type 1 CharStrings and Type 2 CharStrings this is done a little differently.- Returns:
- number that was read.
- Throws:
IOException- if stream reading error occurs.
-