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.StringBASE25protected CmapSubtablecmapDeprecated.protected CmapLookupcmapLookupprivate PDDocumentdocumentprivate booleanembedSubsetprotected PDFontDescriptorfontDescriptorprivate static intITALICprivate static intOBLIQUEprivate java.util.Set<java.lang.Integer>subsetCodePointsprotected TrueTypeFontttf
-
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 voidaddToSubset(int codePoint)Adds the given Unicode code point to this subset.voidbuildFontFile2(java.io.InputStream ttfStream)protected abstract voidbuildSubset(java.io.InputStream ttfSubset, java.lang.String tag, java.util.Map<java.lang.Integer,java.lang.Integer> gidToCid)Rebuild a font subset.private PDFontDescriptorcreateFontDescriptor(TrueTypeFont ttf)Creates a new font descriptor dictionary for the given TTF.PDFontDescriptorgetFontDescriptor()Returns the font descriptor.java.lang.StringgetTag(java.util.Map<java.lang.Integer,java.lang.Integer> gidToCid)Returns an uppercase 6-character unique tag for the given subset.TrueTypeFontgetTrueTypeFont()Deprecated.(package private) booleanisEmbeddingPermitted(TrueTypeFont ttf)Returns true if the fsType in the OS/2 table permits embedding.private booleanisSubsettingPermitted(TrueTypeFont ttf)Returns true if the fsType in the OS/2 table permits subsetting.booleanneedsSubset()Returns true if the font needs to be subset.voidsubset()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
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:SubsetterAdds the given Unicode code point to this subset.- Specified by:
addToSubsetin interfaceSubsetter- Parameters:
codePoint- Unicode code point
-
subset
public void subset() throws java.io.IOExceptionDescription copied from interface:SubsetterSubset 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.IOExceptionRebuild 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.
-
-