Package org.verapdf.pd.font.cff
Class CFFType1FontProgram
- java.lang.Object
-
- org.verapdf.pd.font.cff.CFFType1FontProgram
-
- All Implemented Interfaces:
FontProgram
public class CFFType1FontProgram extends Object implements FontProgram
Instance of this class represent a Type1 font from FontSet of CFF file.- Author:
- Sergey Shemyakov
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanattemptedParsingprotected longcharSetOffsetprotected CFFIndexcharStringsprotected longcharStringsOffsetprotected intcharStringTypeprotected static float[]DEFAULT_FONT_MATRIXprotected intdefaultWidthXprotected CFFIndexdefinedNamesprotected float[]fontMatrixprotected CFFIndexglobalSubrsprotected booleanisSubsetprotected intnGlyphsprotected intnominalWidthXprotected longprivateDictOffsetprotected longprivateDictSizeprotected SeekableInputStreamsourceprotected ArrayList<CFFNumber>stackprotected longsubrsOffsetprotected booleansuccessfullyParsedprotected longtopDictBeginOffsetprotected longtopDictEndOffsetprotected Stringweightprotected CharStringsWidthswidths
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontainsCID(int cid)Method works only for fonts where cid notation is used.booleancontainsCode(int code)Checks if font contains character with given code.booleancontainsGID(int gid)booleancontainsGlyph(String glyphName)Checks if this font program has glyph for given glyph name.DoublegetAscent()static CFFType1FontProgramgetCFFType1(FontProgram fontProgram)Gets CFF Type 1 font program for given font program (CFF font program with inner CFF Type 1 or CFF Type 1).Set<String>getCharSet()DoublegetDescent()String[]getEncoding()ASFileStreamClosergetFontProgramResource()StringgetGlyphName(int code)Returns glyph name for glyph with given code.intgetNGlyphs()protected StringgetStringBySID(int sid)StringgetWeight()floatgetWidth(int charCode)Returns width of glyph for given character code.floatgetWidth(String charName)Returns width of glyph for given glyph name.floatgetWidthFromGID(int gid)booleanisAttemptedParsing()booleanisSuccessfulParsing()voidparseFont()This method does parsing of font, after it all the data needed should be extracted.protected intreadCard16()protected intreadCard8()protected voidreadCharStrings()protected voidreadHeader()protected CFFIndexreadIndex()protected CFFNumberreadNumber()protected voidreadPrivateDictUnit()protected voidreadTopDictOneByteOps(int lastRead)protected voidreadTopDictTwoByteOps(int lastRead)protected voidreadTopDictUnit()-
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
getFontProgramResource, getWeight
-
-
-
-
Field Detail
-
attemptedParsing
protected boolean attemptedParsing
-
successfullyParsed
protected boolean successfullyParsed
-
DEFAULT_FONT_MATRIX
protected static final float[] DEFAULT_FONT_MATRIX
-
globalSubrs
protected CFFIndex globalSubrs
-
isSubset
protected boolean isSubset
-
privateDictOffset
protected long privateDictOffset
-
privateDictSize
protected long privateDictSize
-
topDictBeginOffset
protected long topDictBeginOffset
-
topDictEndOffset
protected long topDictEndOffset
-
fontMatrix
protected float[] fontMatrix
-
charStringsOffset
protected long charStringsOffset
-
charSetOffset
protected long charSetOffset
-
charStringType
protected int charStringType
-
weight
protected String weight
-
nGlyphs
protected int nGlyphs
-
charStrings
protected CFFIndex charStrings
-
widths
protected CharStringsWidths widths
-
defaultWidthX
protected int defaultWidthX
-
nominalWidthX
protected int nominalWidthX
-
subrsOffset
protected long subrsOffset
-
source
protected SeekableInputStream source
-
definedNames
protected CFFIndex definedNames
-
-
Method Detail
-
parseFont
public void parseFont() throws IOExceptionThis 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.
-
readTopDictOneByteOps
protected void readTopDictOneByteOps(int lastRead)
-
getGlyphName
public String getGlyphName(int code)
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.
-
getAscent
public Double getAscent()
- Specified by:
getAscentin interfaceFontProgram
-
getDescent
public Double getDescent()
- Specified by:
getDescentin interfaceFontProgram
-
getWidth
public float getWidth(int charCode)
Returns width of glyph for given character code.- Specified by:
getWidthin interfaceFontProgram- Parameters:
charCode- is code for glyph.- Returns:
- width of corresponding glyph or -1 if glyph is not found.
-
getWidthFromGID
public float getWidthFromGID(int gid)
-
containsGID
public boolean containsGID(int gid)
-
containsGlyph
public boolean containsGlyph(String glyphName)
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.
-
getWidth
public float getWidth(String charName)
Returns width of glyph for given glyph name.- Specified by:
getWidthin interfaceFontProgram- Parameters:
charName- 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.
-
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.
-
getEncoding
public String[] getEncoding()
-
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.
-
getCFFType1
public static CFFType1FontProgram getCFFType1(FontProgram fontProgram)
Gets CFF Type 1 font program for given font program (CFF font program with inner CFF Type 1 or CFF Type 1).- Returns:
- CFF Type 1 font program or null if no CFF Type 1 font program can be obtained.
-
readTopDictUnit
protected void readTopDictUnit() throws IOException- Throws:
IOException
-
readTopDictTwoByteOps
protected void readTopDictTwoByteOps(int lastRead) throws IOException- Throws:
IOException
-
readCharStrings
protected void readCharStrings() throws IOException- Throws:
IOException
-
readPrivateDictUnit
protected void readPrivateDictUnit() throws IOException- Throws:
IOException
-
getNGlyphs
public int getNGlyphs()
- Returns:
- amount of glyphs in the font.
-
getFontProgramResource
public ASFileStreamCloser getFontProgramResource()
-
getWeight
public String getWeight()
-
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
-
-