Package org.verapdf.pd.font.cff
Class CFFFontProgram
- java.lang.Object
-
- org.verapdf.pd.font.cff.CFFFontProgram
-
- All Implemented Interfaces:
FontProgram
public class CFFFontProgram extends Object implements FontProgram
This class starts parsing for all inner CFF fonts and contains fonts parsed.- Author:
- Sergey Shemyakov
-
-
Field Summary
Fields Modifier and Type Field Description protected CFFIndex
definedNames
protected SeekableInputStream
source
-
Constructor Summary
Constructors Constructor Description CFFFontProgram(ASInputStream stream, CMap cMap, boolean isSubset)
Constructor from stream.
-
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.Double
getAscent()
List<Integer>
getCIDList()
Double
getDescent()
FontProgram
getFont()
ASFileStreamCloser
getFontProgramResource()
String
getGlyphName(int code)
Returns glyph name for glyph with given code.protected String
getStringBySID(int sid)
String
getWeight()
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
isAttemptedParsing()
boolean
isCIDFont()
boolean
isSuccessfulParsing()
void
parseFont()
This method does parsing of font, after it all the data needed should be extracted.protected int
readCard16()
protected int
readCard8()
protected void
readHeader()
protected CFFIndex
readIndex()
protected CFFNumber
readNumber()
-
-
-
Field Detail
-
source
protected SeekableInputStream source
-
definedNames
protected CFFIndex definedNames
-
-
Constructor Detail
-
CFFFontProgram
public CFFFontProgram(ASInputStream stream, CMap cMap, boolean isSubset) throws IOException
Constructor from stream.- Parameters:
stream
- is stream with CFF program.- Throws:
IOException
- if creation of @{link SeekableStream} fails.
-
-
Method Detail
-
parseFont
public void parseFont() throws IOException
This method does parsing of font, after it all the data needed should be extracted.- Specified by:
parseFont
in interfaceFontProgram
- Throws:
IOException
- if error in font parsing occurs.
-
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.
-
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.
-
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.
-
isCIDFont
public boolean isCIDFont()
- Returns:
- true if this font is CFF CID font.
-
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.
-
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.
-
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.
-
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.
-
getFont
public FontProgram getFont()
- Returns:
- CID font or Type1 font that is presented by CFF program.
-
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
-
readCard8
protected int readCard8() throws IOException
- Throws:
IOException
-
readCard16
protected int readCard16() throws IOException
- Throws:
IOException
-
readIndex
protected CFFIndex readIndex() throws IOException
- Throws:
IOException
-
readHeader
protected void readHeader() throws IOException
- Throws:
IOException
-
readNumber
protected CFFNumber readNumber() throws IOException
- Throws:
IOException
-
getStringBySID
protected String getStringBySID(int sid) throws IOException
- Throws:
IOException
-
-