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[]
encodingMappingArray
protected org.verapdf.pd.font.truetype.TrueTypeFontParser
parser
protected 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 Double
getAscent()
Double
getDescent()
ASFileStreamCloser
getFontProgramResource()
int
getNGlyphs()
int
getNrOfCMaps()
String
getWeight()
protected float
getWidthWithCheck(int gid)
boolean
isAttemptedParsing()
boolean
isCmapPresent(int platformID, int encodingID)
Returns true if cmap table with given platform ID and encoding ID is present in the font.boolean
isSuccessfulParsing()
void
parseFont()
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 IOException
Parses True Type font from given stream and extracts all the data needed.- Specified by:
parseFont
in 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:
isAttemptedParsing
in interfaceFontProgram
- Returns:
- true if font parsing has been attempted.
-
isSuccessfulParsing
public boolean isSuccessfulParsing()
- Specified by:
isSuccessfulParsing
in interfaceFontProgram
- Returns:
- true if font was successfully parsed.
-
getFontProgramResource
public ASFileStreamCloser getFontProgramResource()
- Specified by:
getFontProgramResource
in interfaceFontProgram
- Returns:
- file stream closer that handles the closing of font program stream or null if stream is memory stream.
-
getWeight
public String getWeight()
- Specified by:
getWeight
in interfaceFontProgram
-
getAscent
public Double getAscent()
- Specified by:
getAscent
in interfaceFontProgram
-
getDescent
public Double getDescent()
- Specified by:
getDescent
in interfaceFontProgram
-
-