Package org.verapdf.pd.font.truetype
Class TrueTypeFontProgram
- java.lang.Object
-
- org.verapdf.pd.font.truetype.BaseTrueTypeProgram
-
- org.verapdf.pd.font.truetype.TrueTypeFontProgram
-
- All Implemented Interfaces:
FontProgram
public class TrueTypeFontProgram extends BaseTrueTypeProgram implements FontProgram
Represents TrueTypeFontProgram.- Author:
- Sergey Shemyakov
-
-
Field Summary
-
Fields inherited from class org.verapdf.pd.font.truetype.BaseTrueTypeProgram
encodingMappingArray, parser, widths
-
-
Constructor Summary
Constructors Constructor Description TrueTypeFontProgram(ASInputStream stream, boolean isSymbolic, COSObject encoding)
Constructor from stream containing font data, and encoding details.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
containsCID(int cid)
Method works only for fonts where cid notation is used.boolean
containsCode(int code)
Checks if font contains character with given code.boolean
containsGlyph(String glyphName)
Checks if this font program has glyph for given glyph name.String
getGlyphName(int code)
Returns glyph name for glyph with given code.float
getWidth(int code)
Returns width of glyph for given character code.float
getWidth(String glyphName)
Returns width of glyph for given glyph name.boolean
isSymbolic()
void
parseFont()
Parses True Type font from given stream and extracts all the data needed.-
Methods inherited from class org.verapdf.pd.font.truetype.BaseTrueTypeProgram
getAscent, getDescent, getFontProgramResource, getNGlyphs, getNrOfCMaps, getWeight, getWidthWithCheck, isAttemptedParsing, isCmapPresent, isSuccessfulParsing
-
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
getAscent, getDescent, getFontProgramResource, getWeight, isAttemptedParsing, isSuccessfulParsing
-
-
-
-
Constructor Detail
-
TrueTypeFontProgram
public TrueTypeFontProgram(ASInputStream stream, boolean isSymbolic, COSObject encoding) throws IOException
Constructor from stream containing font data, and encoding details.- Parameters:
stream
- is stream containing font data.isSymbolic
- is true if font is marked as symbolic.encoding
- is value of /Encoding in font dictionary.- Throws:
IOException
- if creation of @{link SeekableStream} fails.
-
-
Method Detail
-
parseFont
public void parseFont() throws IOException
Description copied from class:BaseTrueTypeProgram
Parses True Type font from given stream and extracts all the data needed.- Specified by:
parseFont
in interfaceFontProgram
- Overrides:
parseFont
in classBaseTrueTypeProgram
- Throws:
IOException
- if stream-reading error occurs.
-
containsCode
public boolean containsCode(int code)
Checks if font contains character with given code.- Specified by:
containsCode
in interfaceFontProgram
- Parameters:
code
- is character code.- Returns:
- true if font contains character with given code.
-
getWidth
public float getWidth(int code)
Returns width of glyph for given character code.- Specified by:
getWidth
in interfaceFontProgram
- Parameters:
code
- is code for glyph.- Returns:
- width of corresponding glyph or -1 if glyph is not found.
-
getGlyphName
public String getGlyphName(int code)
Description copied from interface:FontProgram
Returns glyph name for glyph with given code.- Specified by:
getGlyphName
in interfaceFontProgram
- Parameters:
code
- is code of glyph.- Returns:
- glyph name.
-
getWidth
public float getWidth(String glyphName)
Returns width of glyph for given glyph name.- Specified by:
getWidth
in interfaceFontProgram
- Parameters:
glyphName
- is name for glyph.- Returns:
- width of corresponding glyph or -1 if glyph is not found.
-
containsGlyph
public boolean containsGlyph(String glyphName)
Description copied from interface:FontProgram
Checks if this font program has glyph for given glyph name.- Specified by:
containsGlyph
in interfaceFontProgram
- Parameters:
glyphName
- is the name of glyph.- Returns:
- true if this font program has glyph for given name.
-
isSymbolic
public boolean isSymbolic()
- Returns:
- true if font is symbolic.
-
containsCID
public boolean containsCID(int cid)
Description copied from interface:FontProgram
Method works only for fonts where cid notation is used.- Specified by:
containsCID
in interfaceFontProgram
- Returns:
- true if font a is cid font and contains given cid.
-
-