Package org.verapdf.pd.font.truetype
Class BaseTrueTypeProgram
- java.lang.Object
-
- org.verapdf.pd.font.truetype.BaseTrueTypeProgram
-
- All Implemented Interfaces:
FontProgram
- Direct Known Subclasses:
CIDFontType2Program,TrueTypeFontProgram
public abstract class BaseTrueTypeProgram extends Object implements FontProgram
Base class for TrueTypeFontProgram and CIDFontType2Program.- Author:
- Sergey Shemyakov
-
-
Field Summary
Fields Modifier and Type Field Description protected String[]encodingMappingArrayprotected org.verapdf.pd.font.truetype.TrueTypeFontParserparserprotected float[]widths
-
Constructor Summary
Constructors Constructor Description BaseTrueTypeProgram(ASInputStream stream)Constructor from stream containing font data, and encoding details.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ASFileStreamClosergetFontProgramResource()intgetNGlyphs()intgetNrOfCMaps()protected floatgetWidthWithCheck(int gid)booleanisAttemptedParsing()booleanisCmapPresent(int platformID, int encodingID)Returns true if cmap table with given platform ID and encoding ID is present in the font.booleanisSuccessfulParsing()voidparseFont()Parses True Type font from given stream and extracts all the data needed.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.verapdf.pd.font.FontProgram
containsCID, containsCode, containsGlyph, getGlyphName, getWidth, getWidth
-
-
-
-
Field Detail
-
widths
protected float[] widths
-
parser
protected org.verapdf.pd.font.truetype.TrueTypeFontParser parser
-
encodingMappingArray
protected String[] encodingMappingArray
-
-
Constructor Detail
-
BaseTrueTypeProgram
public BaseTrueTypeProgram(ASInputStream stream) throws IOException
Constructor from stream containing font data, and encoding details.- Parameters:
stream- is stream containing font data.- Throws:
IOException- if creation of @{link SeekableStream} fails.
-
-
Method Detail
-
parseFont
public void parseFont() throws IOExceptionParses True Type font from given stream and extracts all the data needed.- Specified by:
parseFontin interfaceFontProgram- Throws:
IOException- if stream-reading error occurs.
-
getNrOfCMaps
public int getNrOfCMaps()
- Returns:
- array, containing platform ID and encoding ID for each cmap in this True Type font.
-
getNGlyphs
public int getNGlyphs()
- Returns:
- number of glyphs in this font.
-
isCmapPresent
public boolean isCmapPresent(int platformID, int encodingID)Returns true if cmap table with given platform ID and encoding ID is present in the font.- Parameters:
platformID- is platform ID of requested cmap.encodingID- is encoding ID of requested cmap.- Returns:
- true if requested cmap is present.
-
getWidthWithCheck
protected float getWidthWithCheck(int gid)
-
isAttemptedParsing
public boolean isAttemptedParsing()
- Specified by:
isAttemptedParsingin interfaceFontProgram- Returns:
- true if font parsing has been attempted.
-
isSuccessfulParsing
public boolean isSuccessfulParsing()
- Specified by:
isSuccessfulParsingin interfaceFontProgram- Returns:
- true if font was successfully parsed.
-
getFontProgramResource
public ASFileStreamCloser getFontProgramResource()
- Specified by:
getFontProgramResourcein interfaceFontProgram- Returns:
- file stream closer that handles the closing of font program stream or null if stream is memory stream.
-
-