TTFSubsetter
Date: 2017-05-25

org.apache.fontbox.ttf

## Class TTFSubsetter

- java.lang.Object
- - org.apache.fontbox.ttf.TTFSubsetter

-     public final class TTFSubsetter
      extends java.lang.Object

  Subsetter for TrueType (TTF) fonts.

  Originally developed by Wolfgang Glas for Sketch.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `TTFSubsetter(TrueTypeFont ttf)` Creates a subsetter for the given font.
    `TTFSubsetter(TrueTypeFont ttf, java.util.List<java.lang.String> tables)` Creates a subsetter for the given font.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `add(int unicode)` Add the given character code to the subset.
    `void` | `addAll(java.util.Set<java.lang.Integer> unicodeSet)` Add the given character codes to the subset.
    `java.util.Map<java.lang.Integer,java.lang.Integer>` | `getGIDMap()` Returns the map of new -> old GIDs.
    `void` | `setPrefix(java.lang.String prefix)` Sets the prefix to add to the font's PostScript name.
    `void` | `writeToStream(java.io.OutputStream os)` Write the subfont to the given output stream.

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

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

- - ### Constructor Detail

    - #### TTFSubsetter

          public TTFSubsetter(TrueTypeFont ttf)
                       throws java.io.IOException

      Creates a subsetter for the given font.
      Parameters:
        `ttf` - the font to be subset
      Throws:
        `java.io.IOException`

    - #### TTFSubsetter

          public TTFSubsetter(TrueTypeFont ttf,
                      java.util.List<java.lang.String> tables)
                       throws java.io.IOException

      Creates a subsetter for the given font.
      Parameters:
        `ttf` - the font to be subset
        `tables` - optional tables to keep if present
      Throws:
        `java.io.IOException`

  - ### Method Detail

    - #### setPrefix

          public void setPrefix(java.lang.String prefix)

      Sets the prefix to add to the font's PostScript name.

    - #### add

          public void add(int unicode)

      Add the given character code to the subset.
      Parameters:
        `unicode` - character code

    - #### addAll

          public void addAll(java.util.Set<java.lang.Integer> unicodeSet)

      Add the given character codes to the subset.
      Parameters:
        `unicodeSet` - character code set

    - #### getGIDMap

          public java.util.Map<java.lang.Integer,java.lang.Integer> getGIDMap()
                                                                       throws java.io.IOException

      Returns the map of new -> old GIDs.
      Throws:
        `java.io.IOException`

    - #### writeToStream

          public void writeToStream(java.io.OutputStream os)
                             throws java.io.IOException

      Write the subfont to the given output stream.
      Parameters:
        `os` - the stream used for writing. It will be closed by this method.
      Throws:
        `java.io.IOException` - if something went wrong.
        `java.lang.IllegalStateException` - if the subset is empty.