org.apache.fontbox.cff

## Class CFFFont

- java.lang.Object
- - org.apache.fontbox.cff.CFFFont

All Implemented Interfaces:
  FontBoxFont

Direct Known Subclasses:
  CFFCIDFont, CFFType1Font

    public abstract class CFFFont
    extends Object
    implements FontBoxFont

An Adobe Compact Font Format (CFF) font. Thread safe.

Author:
  Villu Ruusmann, John Hewson

### Field Summary

Fields
`protected byte[][]` `charStrings`
`protected byte[][]` `globalSubrIndex`
`protected Map<String,Object>` `topDict`

### Constructor Summary

Constructors
Constructor and Description
`CFFFont()`

### Method Summary

All Methods Instance Methods Abstract Methods Concrete Methods
`void` `addValueToTopDict(String name, Object value)` Adds the given key/value pair to the top dictionary.
`CFFCharset` `getCharset()` Returns the CFFCharset of the font.
`List<byte[]>` `getCharStringBytes()` Returns the character strings dictionary.
`byte[]` `getData()` Returns the CFF data.
`BoundingBox` `getFontBBox()` Returns the FontBBox.
`List<Number>` `getFontMatrix()` Returns the FontMatrix.
`List<byte[]>` `getGlobalSubrIndex()` Returns the list containing the global subroutines.
`String` `getName()` The name of the font.
`int` `getNumCharStrings()` Returns the number of charstrings in the font.
`Map<String,Object>` `getTopDict()` Returns the top dictionary.
`abstract Type2CharString` `getType2CharString(int cidOrGid)` Returns the Type 2 charstring for the given CID.
`String` `toString()`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface org.apache.fontbox.FontBoxFont

`getPath, getWidth, hasGlyph`

### Field Detail

#### topDict

    protected final Map<String,Object> topDict

#### charStrings

    protected byte[][] charStrings

#### globalSubrIndex

    protected byte[][] globalSubrIndex

### Constructor Detail

#### CFFFont

    public CFFFont()

### Method Detail

#### getName

    public String getName()

The name of the font.

Specified by:
  `getName` in interface `FontBoxFont`
Returns:
  the name of the font

#### addValueToTopDict

    public void addValueToTopDict(String name,
                                  Object value)

Adds the given key/value pair to the top dictionary.

Parameters:
  `name` - the given key
  `value` - the given value

#### getTopDict

    public Map<String,Object> getTopDict()

Returns the top dictionary.

Returns:
  the dictionary

#### getFontMatrix

    public List<Number> getFontMatrix()

Returns the FontMatrix.

Specified by:
  `getFontMatrix` in interface `FontBoxFont`
Returns:
  the font matrix

#### getFontBBox

    public BoundingBox getFontBBox()
                            throws IOException

Returns the FontBBox.

Specified by:
  `getFontBBox` in interface `FontBoxFont`
Returns:
  the bounding box of the font
Throws:
  `IOException` - if there are less than 4 numbers

#### getCharset

    public CFFCharset getCharset()

Returns the CFFCharset of the font.

Returns:
  the charset

#### getCharStringBytes

    public final List<byte[]> getCharStringBytes()

Returns the character strings dictionary. For expert users only.

Returns:
  the character strings dictionary as a list of byte arrays.

#### getData

    public byte[] getData()
                   throws IOException

Returns the CFF data.

Returns:
  the cff data as byte array
Throws:
  `IOException` - if the data could not be read

#### getNumCharStrings

    public int getNumCharStrings()

Returns the number of charstrings in the font.

Returns:
  the number of charstrings

#### getGlobalSubrIndex

    public List<byte[]> getGlobalSubrIndex()

Returns the list containing the global subroutines.

Returns:
  a list of the global subroutines.

#### getType2CharString

    public abstract Type2CharString getType2CharString(int cidOrGid)
                                                throws IOException

Returns the Type 2 charstring for the given CID.

Parameters:
  `cidOrGid` - CID for CIFFont, or GID for Type 1 font
Returns:
  the Type2 charstring of the given cid/gid
Throws:
  `IOException` - if the charstring could not be read

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`