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.
- Author:
- John Hewson
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Implement the callback method to callprocessAllFonts(TrueTypeFontProcessor)
. -
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. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
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.
-
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.
-
-
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
-
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
-