## com.lowagie.text.pdf
Class TrueTypeFontSubSet

    java.lang.Object
      com.lowagie.text.pdf.TrueTypeFontSubSet

     class TrueTypeFontSubSet

extends java.lang.Object

Subsets a True Type font by removing the unneeded glyphs from the font.

Author:
  Paulo Soares (psoares@consiste.pt)

Field Summary
`(package private) static int` `ARG_1_AND_2_ARE_WORDS`
`protected int` `directoryOffset`
`(package private) static int[]` `entrySelectors`
`protected java.lang.String` `fileName` The file name.
`protected int` `fontPtr`
`protected int` `glyfTableRealSize`
`protected java.util.ArrayList` `glyphsInList`
`protected java.util.HashMap` `glyphsUsed`
`(package private) static int` `HEAD_LOCA_FORMAT_OFFSET`
`protected boolean` `includeCmap`
`protected boolean` `includeExtras`
`protected boolean` `locaShortTable`
`protected int[]` `locaTable`
`protected int` `locaTableRealSize`
`(package private) static int` `MORE_COMPONENTS`
`protected byte[]` `newGlyfTable`
`protected int[]` `newLocaTable`
`protected byte[]` `newLocaTableOut`
`protected byte[]` `outFont`
`protected RandomAccessFileOrArray` `rf` The file in use.
`(package private) static int` `TABLE_CHECKSUM`
`(package private) static int` `TABLE_LENGTH`
`(package private) static int` `TABLE_OFFSET`
`protected java.util.HashMap` `tableDirectory` Contains the location of the several tables.
`protected int` `tableGlyphOffset`
`(package private) static java.lang.String[]` `tableNamesCmap`
`(package private) static java.lang.String[]` `tableNamesExtra`
`(package private) static java.lang.String[]` `tableNamesSimple`
`(package private) static int` `WE_HAVE_A_SCALE`
`(package private) static int` `WE_HAVE_A_TWO_BY_TWO`
`(package private) static int` `WE_HAVE_AN_X_AND_Y_SCALE`

Constructor Summary
`TrueTypeFontSubSet(java.lang.String fileName, RandomAccessFileOrArray rf, java.util.HashMap glyphsUsed, int directoryOffset, boolean includeCmap, boolean includeExtras)` Creates a new TrueTypeFontSubSet

Method Summary
`protected void` `assembleFont()`
`protected int` `calculateChecksum(byte[] b)`
`protected void` `checkGlyphComposite(int glyph)`
`protected void` `createNewGlyphTables()`
`protected void` `createTableDirectory()`
`protected void` `flatGlyphs()`
`protected void` `locaTobytes()`
`(package private) byte[]` `process()` Does the actual work of subsetting the font.
`protected void` `readLoca()`
`protected java.lang.String` `readStandardString(int length)` Reads a `String` from the font file as bytes using the Cp1252 encoding.
`protected void` `writeFontInt(int n)`
`protected void` `writeFontShort(int n)`
`protected void` `writeFontString(java.lang.String s)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### tableNamesSimple

    static final java.lang.String[] tableNamesSimple

### tableNamesCmap

    static final java.lang.String[] tableNamesCmap

### tableNamesExtra

    static final java.lang.String[] tableNamesExtra

### entrySelectors

    static final int[] entrySelectors

### TABLE_CHECKSUM

    static final int TABLE_CHECKSUM

See Also:
  Constant Field Values

### TABLE_OFFSET

    static final int TABLE_OFFSET

See Also:
  Constant Field Values

### TABLE_LENGTH

    static final int TABLE_LENGTH

See Also:
  Constant Field Values

### HEAD_LOCA_FORMAT_OFFSET

    static final int HEAD_LOCA_FORMAT_OFFSET

See Also:
  Constant Field Values

### ARG_1_AND_2_ARE_WORDS

    static final int ARG_1_AND_2_ARE_WORDS

See Also:
  Constant Field Values

### WE_HAVE_A_SCALE

    static final int WE_HAVE_A_SCALE

See Also:
  Constant Field Values

### MORE_COMPONENTS

    static final int MORE_COMPONENTS

See Also:
  Constant Field Values

### WE_HAVE_AN_X_AND_Y_SCALE

    static final int WE_HAVE_AN_X_AND_Y_SCALE

See Also:
  Constant Field Values

### WE_HAVE_A_TWO_BY_TWO

    static final int WE_HAVE_A_TWO_BY_TWO

See Also:
  Constant Field Values

### tableDirectory

    protected java.util.HashMap tableDirectory

  Contains the location of the several tables. The key is the name of the table and the value is an `int[3]` where position 0 is the checksum, position 1 is the offset from the start of the file and position 2 is the length of the table.

### rf

    protected RandomAccessFileOrArray rf

  The file in use.

### fileName

    protected java.lang.String fileName

  The file name.

### includeCmap

    protected boolean includeCmap

### includeExtras

    protected boolean includeExtras

### locaShortTable

    protected boolean locaShortTable

### locaTable

    protected int[] locaTable

### glyphsUsed

    protected java.util.HashMap glyphsUsed

### glyphsInList

    protected java.util.ArrayList glyphsInList

### tableGlyphOffset

    protected int tableGlyphOffset

### newLocaTable

    protected int[] newLocaTable

### newLocaTableOut

    protected byte[] newLocaTableOut

### newGlyfTable

    protected byte[] newGlyfTable

### glyfTableRealSize

    protected int glyfTableRealSize

### locaTableRealSize

    protected int locaTableRealSize

### outFont

    protected byte[] outFont

### fontPtr

    protected int fontPtr

### directoryOffset

    protected int directoryOffset

Constructor Detail

### TrueTypeFontSubSet

    TrueTypeFontSubSet(java.lang.String fileName,
                       RandomAccessFileOrArray rf,
                       java.util.HashMap glyphsUsed,
                       int directoryOffset,
                       boolean includeCmap,
                       boolean includeExtras)

  Creates a new TrueTypeFontSubSet

  Parameters:
    `directoryOffset` - The offset from the start of the file to the table directory
    `fileName` - the file name of the font
    `glyphsUsed` - the glyphs used
    `includeCmap` - `true` if the table cmap is to be included in the generated font

Method Detail

### process

    byte[] process()
             throws java.io.IOException,
                    DocumentException

  Does the actual work of subsetting the font.

  Returns:
    the subset font
  Throws:
    `java.io.IOException` - on error
    `DocumentException` - on error

### assembleFont

    protected void assembleFont()
                         throws java.io.IOException

  Throws:
    `java.io.IOException`

### createTableDirectory

    protected void createTableDirectory()
                                 throws java.io.IOException,
                                        DocumentException

  Throws:
    `java.io.IOException`
    `DocumentException`

### readLoca

    protected void readLoca()
                     throws java.io.IOException,
                            DocumentException

  Throws:
    `java.io.IOException`
    `DocumentException`

### createNewGlyphTables

    protected void createNewGlyphTables()
                                 throws java.io.IOException

  Throws:
    `java.io.IOException`

### locaTobytes

    protected void locaTobytes()

### flatGlyphs

    protected void flatGlyphs()
                       throws java.io.IOException,
                              DocumentException

  Throws:
    `java.io.IOException`
    `DocumentException`

### checkGlyphComposite

    protected void checkGlyphComposite(int glyph)
                                throws java.io.IOException

  Throws:
    `java.io.IOException`

### readStandardString

    protected java.lang.String readStandardString(int length)
                                           throws java.io.IOException

  Reads a `String` from the font file as bytes using the Cp1252 encoding.

  Parameters:
    `length` - the length of bytes to read
  Returns:
    the `String` read
  Throws:
    `java.io.IOException` - the font file could not be read

### writeFontShort

    protected void writeFontShort(int n)

### writeFontInt

    protected void writeFontInt(int n)

### writeFontString

    protected void writeFontString(java.lang.String s)

### calculateChecksum

    protected int calculateChecksum(byte[] b)

Hosted by Hostbasket