Package org.apache.pdfbox.pdmodel.font
Class TrueTypeEmbedder
java.lang.Object
org.apache.pdfbox.pdmodel.font.TrueTypeEmbedder
- All Implemented Interfaces:
Subsetter
- Direct Known Subclasses:
PDCIDFontType2Embedder
,PDTrueTypeFontEmbedder
Common functionality for embedding TrueType fonts.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
protected final CmapSubtable
Deprecated.protected final CmapLookup
private final PDDocument
private final boolean
protected PDFontDescriptor
private static final int
private static final int
protected TrueTypeFont
-
Constructor Summary
ConstructorsConstructorDescriptionTrueTypeEmbedder
(PDDocument document, COSDictionary dict, TrueTypeFont ttf, boolean embedSubset) Creates a new TrueType font for embedding. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addToSubset
(int codePoint) Adds the given Unicode code point to this subset.void
buildFontFile2
(InputStream ttfStream) protected abstract void
buildSubset
(InputStream ttfSubset, String tag, Map<Integer, Integer> gidToCid) Rebuild a font subset.private PDFontDescriptor
Creates a new font descriptor dictionary for the given TTF.Returns the font descriptor.Returns an uppercase 6-character unique tag for the given subset.Deprecated.(package private) boolean
Returns true if the fsType in the OS/2 table permits embedding.private boolean
Returns true if the fsType in the OS/2 table permits subsetting.boolean
Returns true if the font needs to be subset.void
subset()
Subset this font now.
-
Field Details
-
ITALIC
private static final int ITALIC- See Also:
-
OBLIQUE
private static final int OBLIQUE- See Also:
-
BASE25
- See Also:
-
document
-
ttf
-
fontDescriptor
-
cmap
Deprecated.For API backwards compatibility. -
cmapLookup
-
subsetCodePoints
-
embedSubset
private final boolean embedSubset
-
-
Constructor Details
-
TrueTypeEmbedder
TrueTypeEmbedder(PDDocument document, COSDictionary dict, TrueTypeFont ttf, boolean embedSubset) throws IOException Creates a new TrueType font for embedding.- Throws:
IOException
-
-
Method Details
-
buildFontFile2
- Throws:
IOException
-
isEmbeddingPermitted
Returns true if the fsType in the OS/2 table permits embedding.- Throws:
IOException
-
isSubsettingPermitted
Returns true if the fsType in the OS/2 table permits subsetting.- Throws:
IOException
-
createFontDescriptor
Creates a new font descriptor dictionary for the given TTF.- Throws:
IOException
-
getTrueTypeFont
Deprecated.Returns the FontBox font. -
getFontDescriptor
Returns the font descriptor. -
addToSubset
public void addToSubset(int codePoint) Description copied from interface:Subsetter
Adds the given Unicode code point to this subset.- Specified by:
addToSubset
in interfaceSubsetter
- Parameters:
codePoint
- Unicode code point
-
subset
Description copied from interface:Subsetter
Subset this font now.- Specified by:
subset
in interfaceSubsetter
- Throws:
IOException
- if the font could not be read
-
needsSubset
public boolean needsSubset()Returns true if the font needs to be subset. -
buildSubset
protected abstract void buildSubset(InputStream ttfSubset, String tag, Map<Integer, Integer> gidToCid) throws IOExceptionRebuild a font subset.- Throws:
IOException
-
getTag
Returns an uppercase 6-character unique tag for the given subset.
-