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 java.util.Set<java.lang.Integer>allGlyphIdsprivate static java.lang.StringBASE25protected CmapLookupcmapLookupprivate PDDocumentdocumentprivate booleanembedSubsetprotected PDFontDescriptorfontDescriptorprivate static intITALICprivate static intOBLIQUEprivate java.util.Set<java.lang.Integer>subsetCodePointsprivate static java.util.List<java.lang.String>TABLESprotected 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 Modifier and Type Method Description voidaddGlyphIds(java.util.Set<java.lang.Integer> glyphIds)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.(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
-
TABLES
private static final java.util.List<java.lang.String> TABLES
-
document
private final PDDocument document
-
ttf
protected TrueTypeFont ttf
-
fontDescriptor
protected PDFontDescriptor fontDescriptor
-
cmapLookup
protected final CmapLookup cmapLookup
-
subsetCodePoints
private final java.util.Set<java.lang.Integer> subsetCodePoints
-
embedSubset
private final boolean embedSubset
-
allGlyphIds
private final java.util.Set<java.lang.Integer> allGlyphIds
-
-
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 final void buildFontFile2(java.io.InputStream ttfStream) throws java.io.IOException- Throws:
java.io.IOException
-
isEmbeddingPermitted
final 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
-
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
-
addGlyphIds
public void addGlyphIds(java.util.Set<java.lang.Integer> glyphIds)
-
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.
-
-