Top Description Inners Fields Constructors Methods
org.apache.fontbox.ttf

public Class TrueTypeCollection

extends Object
implements Closeable
Class Inheritance
All Implemented Interfaces
java.io.Closeable, java.lang.AutoCloseable
Imports
java.io.Closeable, .File, .IOException, .InputStream, org.apache.pdfbox.io.IOUtils, .RandomAccessRead, .RandomAccessReadBuffer, .RandomAccessReadBufferedFile

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

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
public static interface

Field Summary

Modifier and TypeField and Description
private final long[]
private final int
private final TTFDataStream

Constructor Summary

AccessConstructor and Description
public
TrueTypeCollection(File
The TTC file.
file
)

Creates a new TrueTypeCollection from a .ttc file.

public
TrueTypeCollection(InputStream
A TTC input stream.
stream
)

Creates a new TrueTypeCollection from a .ttc input stream.

private
TrueTypeCollection(TTFDataStream stream)

Creates a new TrueTypeCollection from a RandomAccessRead.

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements java.io.Closeable.close.

Closes this stream and releases any system resources associated with it.

private static TTFDataStream
createBufferedDataStream(RandomAccessRead randomAccessRead, boolean closeAfterReading)

private TTFParser
private TrueTypeFont
getFontAtIndex(int idx)

public TrueTypeFont

Returns:

The found font, nor null if none is found.
getFontByName
(String
The postscript name of the font.
name
)

Get a TT font from a collection.

public static void
processAllFontHeaders(File ttcFile, TrueTypeCollection.TrueTypeFontHeadersProcessor
the object with the callback method.
trueTypeFontProcessor
)

Run the callback for each TT font in the collection.

public void
processAllFonts(TrueTypeCollection.TrueTypeFontProcessor
the object with the callback method.
trueTypeFontProcessor
)

Run the callback for each TT font in the collection.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

fontOffsetsback to summary
private final long[] fontOffsets
numFontsback to summary
private final int numFonts
streamback to summary
private final TTFDataStream stream

Constructor Detail

TrueTypeCollectionback to summary
public TrueTypeCollection(File file) throws IOException

Creates a new TrueTypeCollection from a .ttc file.

Parameters
file:File

The TTC file.

Exceptions
IOException:
If the font could not be parsed.
TrueTypeCollectionback to summary
public TrueTypeCollection(InputStream stream) throws IOException

Creates a new TrueTypeCollection from a .ttc input stream.

Parameters
stream:InputStream

A TTC input stream.

Exceptions
IOException:
If the font could not be parsed.
TrueTypeCollectionback to summary
private TrueTypeCollection(TTFDataStream stream) throws IOException

Creates a new TrueTypeCollection from a RandomAccessRead.

Exceptions
IOException:
If the font could not be parsed.

Method Detail

closeback to summary
public void close() throws IOException

Implements java.io.Closeable.close.

Doc from java.io.Closeable.close.

Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect.

As noted in AutoCloseable#close(), cases where the close may fail require careful attention. It is strongly advised to relinquish the underlying resources and to internally mark the Closeable as closed, prior to throwing the IOException.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs
createBufferedDataStreamback to summary
private static TTFDataStream createBufferedDataStream(RandomAccessRead randomAccessRead, boolean closeAfterReading) throws IOException
createFontParserAtIndexAndSeekback to summary
private TTFParser createFontParserAtIndexAndSeek(int idx) throws IOException
getFontAtIndexback to summary
private TrueTypeFont getFontAtIndex(int idx) throws IOException
getFontByNameback to summary
public TrueTypeFont getFontByName(String name) throws IOException

Get a TT font from a collection.

Parameters
name:String

The postscript name of the font.

Returns:TrueTypeFont

The found font, nor null if none is found.

Exceptions
IOException:
if there is an error reading the font data
processAllFontHeadersback to summary
public static void processAllFontHeaders(File ttcFile, TrueTypeCollection.TrueTypeFontHeadersProcessor trueTypeFontProcessor) throws IOException

Run the callback for each TT font in the collection.

Parameters
trueTypeFontProcessor:TrueTypeCollection.TrueTypeFontHeadersProcessor

the object with the callback method.

Exceptions
IOException:
if something went wrong when parsing any font
processAllFontsback to summary
public void processAllFonts(TrueTypeCollection.TrueTypeFontProcessor trueTypeFontProcessor) throws IOException

Run the callback for each TT font in the collection.

Parameters
trueTypeFontProcessor:TrueTypeCollection.TrueTypeFontProcessor

the object with the callback method.

Exceptions
IOException:
if something went wrong when parsing any font or calling the TrueTypeFontProcessor
org.apache.fontbox.ttf back to summary

public Interface TrueTypeCollection.TrueTypeFontHeadersProcessor

Annotations
@FunctionalInterface

Implement the callback method to call TrueTypeCollection#processAllFontHeaders(File, TrueTypeFontHeadersProcessor).

Method Summary

Modifier and TypeMethod and Description
public void
process(FontHeaders fontHeaders)

Method Detail

processback to summary
public void process(FontHeaders fontHeaders)
org.apache.fontbox.ttf back to summary

public Interface TrueTypeCollection.TrueTypeFontProcessor

Annotations
@FunctionalInterface

Implement the callback method to call TrueTypeCollection#processAllFonts(TrueTypeFontProcessor).

Method Summary

Modifier and TypeMethod and Description
public void

Method Detail

processback to summary
public void process(TrueTypeFont ttf) throws IOException