Package org.verapdf.pd.font.opentype
Class OpenTypeFontProgram
java.lang.Object
org.verapdf.pd.font.opentype.OpenTypeFontProgram
- All Implemented Interfaces:
FontProgram
Represents OpenType font program.
- Author:
- Sergey Shemyakov
-
Constructor Summary
ConstructorsConstructorDescriptionOpenTypeFontProgram(ASInputStream source, boolean isCFF, boolean isCIDFontType2, boolean isSymbolic, COSObject encoding, CMap externalCMap, boolean isSubset, COSObject cidToGIDMap) Constructor from stream, containing font data, and encoding details. -
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsCID(int cid) Method works only for fonts where cid notation is used.booleancontainsCode(int code) Checks if font contains character with given code.booleancontainsGlyph(String glyphName) Checks if this font program has glyph for given glyph name.getFont()getGlyphName(int code) Returns glyph name for glyph with given code.floatgetWidth(int code) Returns width of glyph for given character code.floatReturns width of glyph for given glyph name.booleanbooleanvoidThis method does parsing of font, after it all the data needed should be extracted.
-
Constructor Details
-
OpenTypeFontProgram
public OpenTypeFontProgram(ASInputStream source, boolean isCFF, boolean isCIDFontType2, boolean isSymbolic, COSObject encoding, CMap externalCMap, boolean isSubset, COSObject cidToGIDMap) Constructor from stream, containing font data, and encoding details.- Parameters:
source- is stream containing font data.isSymbolic- is true if font is marked as symbolic.encoding- is value of /Encoding in font dictionary.
-
-
Method Details
-
getWidth
public float getWidth(int code) Returns width of glyph for given character code.- Specified by:
getWidthin interfaceFontProgram- Parameters:
code- is code for glyph.- Returns:
- width of corresponding glyph or -1 if glyph is not found.
-
getWidth
Returns width of glyph for given glyph name.- Specified by:
getWidthin interfaceFontProgram- Parameters:
glyphName- is name for glyph.- Returns:
- width of corresponding glyph or -1 if glyph is not found.
-
containsCode
public boolean containsCode(int code) Checks if font contains character with given code.- Specified by:
containsCodein interfaceFontProgram- Parameters:
code- is character code.- Returns:
- true if font contains character with given code.
-
containsGlyph
Description copied from interface:FontProgramChecks if this font program has glyph for given glyph name.- Specified by:
containsGlyphin interfaceFontProgram- Parameters:
glyphName- is the name of glyph.- Returns:
- true if this font program has glyph for given name.
-
containsCID
public boolean containsCID(int cid) Description copied from interface:FontProgramMethod works only for fonts where cid notation is used.- Specified by:
containsCIDin interfaceFontProgram- Returns:
- true if font a is cid font and contains given cid.
-
getGlyphName
Description copied from interface:FontProgramReturns glyph name for glyph with given code.- Specified by:
getGlyphNamein interfaceFontProgram- Parameters:
code- is code of glyph.- Returns:
- glyph name.
-
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.
-
parseFont
This method does parsing of font, after it all the data needed should be extracted.- Specified by:
parseFontin interfaceFontProgram- Throws:
IOException- if error in font parsing occurs.
-
getFont
- Returns:
- CFF font or TrueType font, represented by this OpenType font.
-
getFontProgramResource
- Specified by:
getFontProgramResourcein interfaceFontProgram- Returns:
- file stream closer that handles the closing of font program stream or null if stream is memory stream.
-
getWeight
- Specified by:
getWeightin interfaceFontProgram
-
getAscent
- Specified by:
getAscentin interfaceFontProgram
-
getDescent
- Specified by:
getDescentin interfaceFontProgram
-
getCIDList
- Specified by:
getCIDListin interfaceFontProgram
-