org.apache.fontbox.ttf

## Class TrueTypeCollection

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

All Implemented Interfaces:
  Closeable, AutoCloseable

    public class TrueTypeCollection
    extends Object
    implements Closeable

A TrueType Collection, now more properly known as a "Font Collection" as it may contain either TrueType or OpenType fonts.

Author:
  John Hewson

### Nested Class Summary

Nested Classes
`static interface` `TrueTypeCollection.TrueTypeFontHeadersProcessor` Implement the callback method to call `processAllFontHeaders(File, TrueTypeFontHeadersProcessor)`.
`static interface` `TrueTypeCollection.TrueTypeFontProcessor` Implement the callback method to call `processAllFonts(TrueTypeFontProcessor)`.

### Constructor Summary

Constructors
Constructor and Description
`TrueTypeCollection(File file)` Creates a new TrueTypeCollection from a .ttc file.
`TrueTypeCollection(InputStream stream)` Creates a new TrueTypeCollection from a .ttc input stream.

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`void` `close()`
`TrueTypeFont` `getFontByName(String name)` Get a TT font from a collection.
`static void` `processAllFontHeaders(File ttcFile, TrueTypeCollection.TrueTypeFontHeadersProcessor trueTypeFontProcessor)` Run the callback for each TT font in the collection.
`void` `processAllFonts(TrueTypeCollection.TrueTypeFontProcessor trueTypeFontProcessor)` Run the callback for each TT font in the collection.

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

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

### Constructor Detail

#### TrueTypeCollection

    public TrueTypeCollection(File file)
                       throws IOException

Creates a new TrueTypeCollection from a .ttc file.

Parameters:
  `file` - The TTC file.
Throws:
  `IOException` - If the font could not be parsed.

#### TrueTypeCollection

    public TrueTypeCollection(InputStream stream)
                       throws IOException

Creates a new TrueTypeCollection from a .ttc input stream.

Parameters:
  `stream` - A TTC input stream.
Throws:
  `IOException` - If the font could not be parsed.

### Method Detail

#### processAllFonts

    public void processAllFonts(TrueTypeCollection.TrueTypeFontProcessor trueTypeFontProcessor)
                         throws IOException

Run the callback for each TT font in the collection.

Parameters:
  `trueTypeFontProcessor` - the object with the callback method.
Throws:
  `IOException` - if something went wrong when parsing any font or calling the TrueTypeFontProcessor

#### processAllFontHeaders

    public static void processAllFontHeaders(File ttcFile,
                                             TrueTypeCollection.TrueTypeFontHeadersProcessor trueTypeFontProcessor)
                                      throws IOException

Run the callback for each TT font in the collection.

Parameters:
  `trueTypeFontProcessor` - the object with the callback method.
Throws:
  `IOException` - if something went wrong when parsing any font

#### getFontByName

    public TrueTypeFont getFontByName(String name)
                               throws IOException

Get a TT font from a collection.

Parameters:
  `name` - The postscript name of the font.
Returns:
  The found font, nor null if none is found.
Throws:
  `IOException` - if there is an error reading the font data

#### close

    public void close()
               throws IOException

Specified by:
  `close` in interface `Closeable`
Specified by:
  `close` in interface `AutoCloseable`
Throws:
  `IOException`