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
abstract class TrueTypeEmbedder extends java.lang.Object implements Subsetter
Common functionality for embedding TrueType fonts.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
BASE25
protected CmapSubtable
cmap
Deprecated.protected CmapLookup
cmapLookup
private PDDocument
document
private boolean
embedSubset
protected PDFontDescriptor
fontDescriptor
private static int
ITALIC
private static int
OBLIQUE
private java.util.Set<java.lang.Integer>
subsetCodePoints
protected TrueTypeFont
ttf
-
Constructor Summary
Constructors Constructor Description TrueTypeEmbedder(PDDocument document, COSDictionary dict, TrueTypeFont ttf, boolean embedSubset)
Creates a new TrueType font for embedding.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addToSubset(int codePoint)
Adds the given Unicode code point to this subset.void
buildFontFile2(java.io.InputStream ttfStream)
protected abstract void
buildSubset(java.io.InputStream ttfSubset, java.lang.String tag, java.util.Map<java.lang.Integer,java.lang.Integer> gidToCid)
Rebuild a font subset.private PDFontDescriptor
createFontDescriptor(TrueTypeFont ttf)
Creates a new font descriptor dictionary for the given TTF.PDFontDescriptor
getFontDescriptor()
Returns the font descriptor.java.lang.String
getTag(java.util.Map<java.lang.Integer,java.lang.Integer> gidToCid)
Returns an uppercase 6-character unique tag for the given subset.TrueTypeFont
getTrueTypeFont()
Deprecated.private boolean
isEmbeddingPermitted(TrueTypeFont ttf)
Returns true if the fsType in the OS/2 table permits embedding.private boolean
isSubsettingPermitted(TrueTypeFont ttf)
Returns true if the fsType in the OS/2 table permits subsetting.boolean
needsSubset()
Returns true if the font needs to be subset.void
subset()
Subset this font now.
-
-
-
Field Detail
-
ITALIC
private static final int ITALIC
- See Also:
- Constant Field Values
-
OBLIQUE
private static final int OBLIQUE
- See Also:
- Constant Field Values
-
BASE25
private static final java.lang.String BASE25
- See Also:
- Constant Field Values
-
document
private final PDDocument document
-
ttf
protected TrueTypeFont ttf
-
fontDescriptor
protected PDFontDescriptor fontDescriptor
-
cmap
@Deprecated protected final CmapSubtable cmap
Deprecated.For API backwards compatibility.
-
cmapLookup
protected final CmapLookup cmapLookup
-
subsetCodePoints
private final java.util.Set<java.lang.Integer> subsetCodePoints
-
embedSubset
private final boolean embedSubset
-
-
Constructor Detail
-
TrueTypeEmbedder
TrueTypeEmbedder(PDDocument document, COSDictionary dict, TrueTypeFont ttf, boolean embedSubset) throws java.io.IOException
Creates a new TrueType font for embedding.- Throws:
java.io.IOException
-
-
Method Detail
-
buildFontFile2
public void buildFontFile2(java.io.InputStream ttfStream) throws java.io.IOException
- Throws:
java.io.IOException
-
isEmbeddingPermitted
private boolean isEmbeddingPermitted(TrueTypeFont ttf) throws java.io.IOException
Returns true if the fsType in the OS/2 table permits embedding.- Throws:
java.io.IOException
-
isSubsettingPermitted
private boolean isSubsettingPermitted(TrueTypeFont ttf) throws java.io.IOException
Returns true if the fsType in the OS/2 table permits subsetting.- Throws:
java.io.IOException
-
createFontDescriptor
private PDFontDescriptor createFontDescriptor(TrueTypeFont ttf) throws java.io.IOException
Creates a new font descriptor dictionary for the given TTF.- Throws:
java.io.IOException
-
getTrueTypeFont
@Deprecated public TrueTypeFont getTrueTypeFont()
Deprecated.Returns the FontBox font.
-
getFontDescriptor
public PDFontDescriptor 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
public void subset() throws java.io.IOException
Description copied from interface:Subsetter
Subset this font now.
-
needsSubset
public boolean needsSubset()
Returns true if the font needs to be subset.
-
buildSubset
protected abstract void buildSubset(java.io.InputStream ttfSubset, java.lang.String tag, java.util.Map<java.lang.Integer,java.lang.Integer> gidToCid) throws java.io.IOException
Rebuild a font subset.- Throws:
java.io.IOException
-
getTag
public java.lang.String getTag(java.util.Map<java.lang.Integer,java.lang.Integer> gidToCid)
Returns an uppercase 6-character unique tag for the given subset.
-
-