Package org.apache.fontbox.cff
Class CFFType1Font
- java.lang.Object
-
- org.apache.fontbox.cff.CFFFont
-
- org.apache.fontbox.cff.CFFType1Font
-
- All Implemented Interfaces:
EncodedFont,FontBoxFont
public class CFFType1Font extends CFFFont implements EncodedFont
A Type 1-equivalent font program represented in a CFF file. Thread safe.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classCFFType1Font.PrivateType1CharStringReaderPrivate implementation of Type1CharStringReader, because only CFFType1Font can expose this publicly, as CIDFonts only support this for legacy 'seac' commands.
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.Integer,Type2CharString>charStringCacheprivate Type2CharStringParsercharStringParserprivate intdefaultWidthXprivate CFFEncodingencodingprivate byte[][]localSubrIndexprivate intnominalWidthXprivate java.util.Map<java.lang.String,java.lang.Object>privateDictprivate CFFType1Font.PrivateType1CharStringReaderreader-
Fields inherited from class org.apache.fontbox.cff.CFFFont
charStrings, globalSubrIndex, topDict
-
-
Constructor Summary
Constructors Constructor Description CFFType1Font()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidaddToPrivateDict(java.lang.String name, java.lang.Object value)Adds the given key/value pair to the private dictionary.private intgetDefaultWidthX()CFFEncodinggetEncoding()Returns the CFFEncoding of the font.private byte[][]getLocalSubrIndex()private intgetNominalWidthX()private Type2CharStringParsergetParser()java.awt.geom.GeneralPathgetPath(java.lang.String name)Returns the path for the character with the given name.java.util.Map<java.lang.String,java.lang.Object>getPrivateDict()Returns the private dictionary.private java.lang.ObjectgetProperty(java.lang.String name)Type1CharStringgetType1CharString(java.lang.String name)Returns the Type 1 charstring for the given PostScript glyph name.Type2CharStringgetType2CharString(int gid)Returns the Type 1 charstring for the given GID.private Type2CharStringgetType2CharString(int gid, java.lang.String name)floatgetWidth(java.lang.String name)Returns the advance width for the character with the given name.booleanhasGlyph(java.lang.String name)Returns true if the font contains the given glyph.intnameToGID(java.lang.String name)Returns the GID for the given PostScript glyph name.(package private) voidsetEncoding(CFFEncoding encoding)Sets the CFFEncoding of the font.-
Methods inherited from class org.apache.fontbox.cff.CFFFont
addValueToTopDict, getCharset, getCharStringBytes, getData, getFontBBox, getFontMatrix, getGlobalSubrIndex, getName, getNumCharStrings, getTopDict, setCharset, setData, setGlobalSubrIndex, setName, toString
-
-
-
-
Field Detail
-
privateDict
private final java.util.Map<java.lang.String,java.lang.Object> privateDict
-
encoding
private CFFEncoding encoding
-
charStringCache
private final java.util.Map<java.lang.Integer,Type2CharString> charStringCache
-
reader
private final CFFType1Font.PrivateType1CharStringReader reader
-
charStringParser
private Type2CharStringParser charStringParser
-
defaultWidthX
private int defaultWidthX
-
nominalWidthX
private int nominalWidthX
-
localSubrIndex
private byte[][] localSubrIndex
-
-
Method Detail
-
getPath
public java.awt.geom.GeneralPath getPath(java.lang.String name) throws java.io.IOExceptionDescription copied from interface:FontBoxFontReturns the path for the character with the given name.- Specified by:
getPathin interfaceFontBoxFont- Parameters:
name- PostScript glyph name- Returns:
- glyph path
- Throws:
java.io.IOException- if the path could not be read
-
getWidth
public float getWidth(java.lang.String name) throws java.io.IOExceptionDescription copied from interface:FontBoxFontReturns the advance width for the character with the given name.- Specified by:
getWidthin interfaceFontBoxFont- Parameters:
name- PostScript glyph name- Returns:
- glyph advance width
- Throws:
java.io.IOException- if the path could not be read
-
hasGlyph
public boolean hasGlyph(java.lang.String name)
Description copied from interface:FontBoxFontReturns true if the font contains the given glyph.- Specified by:
hasGlyphin interfaceFontBoxFont- Parameters:
name- PostScript glyph name- Returns:
- true if the font contains a glyph with the given name, otherwise false
-
getType1CharString
public Type1CharString getType1CharString(java.lang.String name) throws java.io.IOException
Returns the Type 1 charstring for the given PostScript glyph name.- Parameters:
name- PostScript glyph name- Returns:
- Type1 charstring of the given PostScript glyph name
- Throws:
java.io.IOException- if the charstring could not be read
-
nameToGID
public int nameToGID(java.lang.String name)
Returns the GID for the given PostScript glyph name.- Parameters:
name- a PostScript glyph name.- Returns:
- GID
-
getType2CharString
public Type2CharString getType2CharString(int gid) throws java.io.IOException
Returns the Type 1 charstring for the given GID.- Specified by:
getType2CharStringin classCFFFont- Parameters:
gid- GID- Returns:
- the Type2 charstring of the given cid/gid
- Throws:
java.io.IOException- if the charstring could not be read
-
getType2CharString
private Type2CharString getType2CharString(int gid, java.lang.String name) throws java.io.IOException
- Throws:
java.io.IOException
-
getParser
private Type2CharStringParser getParser()
-
getPrivateDict
public java.util.Map<java.lang.String,java.lang.Object> getPrivateDict()
Returns the private dictionary.- Returns:
- the dictionary
-
addToPrivateDict
void addToPrivateDict(java.lang.String name, java.lang.Object value)Adds the given key/value pair to the private dictionary.- Parameters:
name- the given keyvalue- the given value
-
getEncoding
public CFFEncoding getEncoding()
Returns the CFFEncoding of the font.- Specified by:
getEncodingin interfaceEncodedFont- Returns:
- the encoding
-
setEncoding
void setEncoding(CFFEncoding encoding)
Sets the CFFEncoding of the font.- Parameters:
encoding- the given CFFEncoding
-
getLocalSubrIndex
private byte[][] getLocalSubrIndex()
-
getProperty
private java.lang.Object getProperty(java.lang.String name)
-
getDefaultWidthX
private int getDefaultWidthX()
-
getNominalWidthX
private int getNominalWidthX()
-
-