Package org.apache.fontbox.ttf
Class TrueTypeCollection
java.lang.Object
org.apache.fontbox.ttf.TrueTypeCollection
- All Implemented Interfaces:
Closeable
,AutoCloseable
A TrueType Collection, now more properly known as a "Font Collection" as it may contain either
TrueType or OpenType fonts.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Implement the callback method to callprocessAllFonts(TrueTypeFontProcessor)
. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final long[]
private final int
private final TTFDataStream
-
Constructor Summary
ConstructorsConstructorDescriptionTrueTypeCollection
(File file) Creates a new TrueTypeCollection from a .ttc file.TrueTypeCollection
(InputStream stream) Creates a new TrueTypeCollection from a .ttc input stream.TrueTypeCollection
(TTFDataStream stream) Creates a new TrueTypeCollection from a TTC stream. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
private TrueTypeFont
getFontAtIndex
(int idx) getFontByName
(String name) Get a TT font from a collection.void
processAllFonts
(TrueTypeCollection.TrueTypeFontProcessor trueTypeFontProcessor) Run the callback for each TT font in the collection.
-
Field Details
-
stream
-
numFonts
private final int numFonts -
fontOffsets
private final long[] fontOffsets
-
-
Constructor Details
-
TrueTypeCollection
Creates a new TrueTypeCollection from a .ttc file.- Parameters:
file
- The TTC file.- Throws:
IOException
- If the font could not be parsed.
-
TrueTypeCollection
Creates a new TrueTypeCollection from a .ttc input stream.- Parameters:
stream
- A TTC input stream.- Throws:
IOException
- If the font could not be parsed.
-
TrueTypeCollection
TrueTypeCollection(TTFDataStream stream) throws IOException Creates a new TrueTypeCollection from a TTC stream.- Parameters:
stream
- The TTF file.- Throws:
IOException
- If the font could not be parsed.
-
-
Method Details
-
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
-
getFontAtIndex
- Throws:
IOException
-
getFontByName
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
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-