Package org.verapdf.pd.font.type1
Class BaseCharStringParser
- java.lang.Object
-
- org.verapdf.pd.font.type1.BaseCharStringParser
-
- Direct Known Subclasses:
Type1CharStringParser
public abstract class BaseCharStringParser extends Object
This is base class for Type1CharStringParser and Type2CharStringParser.- Author:
- Sergey Shemyakov
-
-
Field Summary
Fields Modifier and Type Field Description protected intbiasprotected intgBiasprotected CFFIndexglobalSubrsprotected CFFIndexlocalSubrsprotected Stack<CFFNumber>stackprotected Map<Integer,CFFNumber>subrWidths
-
Constructor Summary
Constructors Modifier Constructor Description protectedBaseCharStringParser(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
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidaddStream(ASInputStream is)CFFNumbergetWidth()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 voidsetWidth(CFFNumber width)
-
-
-
Constructor Detail
-
BaseCharStringParser
protected BaseCharStringParser(ASInputStream stream) throws IOException
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 Detail
-
getWidth
public CFFNumber getWidth()
- Returns:
- width of glyph or null if it can't be found in given CharString.
-
setWidth
protected void setWidth(CFFNumber width)
-
readStreams
protected int readStreams(byte[] buffer, int size) throws IOException- Throws:
IOException
-
addStream
protected void addStream(ASInputStream is)
-
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
protected abstract boolean processNextOperator(int nextByte) throws IOExceptionThis 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
protected abstract CFFNumber readNextNumber(int firstByte) throws IOException
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.
-
-