Top Description Fields Constructors Methods
org.apache.pdfbox.pdmodel.font

pack-priv abstract Class TrueTypeEmbedder

extends Object
implements Subsetter
Class Inheritance
All Implemented Interfaces
org.apache.pdfbox.pdmodel.font.Subsetter
Known Direct Subclasses
org.apache.pdfbox.pdmodel.font.PDCIDFontType2Embedder, org.apache.pdfbox.pdmodel.font.PDTrueTypeFontEmbedder
Imports
java.awt.geom.GeneralPath, java.io.ByteArrayInputStream, .ByteArrayOutputStream, .IOException, .InputStream, java.util.ArrayList, .HashSet, .List, .Map, .Set, org.apache.fontbox.ttf.CmapLookup, .HeaderTable, .HorizontalHeaderTable, .OS2WindowsMetricsTable, .PostScriptTable, .TTFParser, .TTFSubsetter, .TrueTypeFont, org.apache.pdfbox.cos.COSDictionary, .COSName, org.apache.pdfbox.pdmodel.PDDocument, org.apache.pdfbox.pdmodel.common.PDRectangle, .PDStream

Common functionality for embedding TrueType fonts.
Authors
Ben Litchfield, John Hewson

Field Summary

Modifier and TypeField and Description
private final Set<Integer>
private static final String
protected final CmapLookup
private final PDDocument
private final boolean
protected PDFontDescriptor
private static final int
private static final int
private final Set<Integer>
protected TrueTypeFont

Constructor Summary

AccessConstructor and Description
pack-priv
TrueTypeEmbedder(PDDocument document, COSDictionary dict, TrueTypeFont ttf, boolean embedSubset)

Creates a new TrueType font for embedding.

Method Summary

Modifier and TypeMethod and Description
public void
addGlyphIds(Set<Integer> glyphIds)

public void
addToSubset(int
Unicode code point
codePoint
)

Implements org.apache.pdfbox.pdmodel.font.Subsetter.addToSubset.

Adds the given Unicode code point to this subset.

public final void
protected abstract void
buildSubset(InputStream ttfSubset, String tag, Map<Integer, Integer> gidToCid)

Rebuild a font subset.

private PDFontDescriptor
createFontDescriptor(TrueTypeFont ttf)

Creates a new font descriptor dictionary for the given TTF.

public PDFontDescriptor
getFontDescriptor()

Returns the font descriptor.

public String
getTag(Map<Integer, Integer> gidToCid)

Returns an uppercase 6-character unique tag for the given subset.

pack-priv final 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.

public boolean
needsSubset()

Returns true if the font needs to be subset.

public void
subset()

Implements org.apache.pdfbox.pdmodel.font.Subsetter.subset.

Subset this font now.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

allGlyphIdsback to summary
private final Set<Integer> allGlyphIds
BASE25back to summary
private static final String BASE25
cmapLookupback to summary
protected final CmapLookup cmapLookup
documentback to summary
private final PDDocument document
embedSubsetback to summary
private final boolean embedSubset
fontDescriptorback to summary
protected PDFontDescriptor fontDescriptor
ITALICback to summary
private static final int ITALIC
OBLIQUEback to summary
private static final int OBLIQUE
subsetCodePointsback to summary
private final Set<Integer> subsetCodePoints
ttfback to summary
protected TrueTypeFont ttf

Constructor Detail

TrueTypeEmbedderback to summary
pack-priv TrueTypeEmbedder(PDDocument document, COSDictionary dict, TrueTypeFont ttf, boolean embedSubset) throws IOException

Creates a new TrueType font for embedding.

Method Detail

addGlyphIdsback to summary
public void addGlyphIds(Set<Integer> glyphIds)
addToSubsetback to summary
public void addToSubset(int codePoint)

Implements org.apache.pdfbox.pdmodel.font.Subsetter.addToSubset.

Doc from org.apache.pdfbox.pdmodel.font.Subsetter.addToSubset.

Adds the given Unicode code point to this subset.

Parameters
codePoint:int

Unicode code point

Annotations
@Override
buildFontFile2back to summary
public final void buildFontFile2(InputStream ttfStream) throws IOException
buildSubsetback to summary
protected abstract void buildSubset(InputStream ttfSubset, String tag, Map<Integer, Integer> gidToCid) throws IOException

Rebuild a font subset.

createFontDescriptorback to summary
private PDFontDescriptor createFontDescriptor(TrueTypeFont ttf) throws IOException

Creates a new font descriptor dictionary for the given TTF.

getFontDescriptorback to summary
public PDFontDescriptor getFontDescriptor()

Returns the font descriptor.

getTagback to summary
public String getTag(Map<Integer, Integer> gidToCid)

Returns an uppercase 6-character unique tag for the given subset.

isEmbeddingPermittedback to summary
pack-priv final boolean isEmbeddingPermitted(TrueTypeFont ttf) throws IOException

Returns true if the fsType in the OS/2 table permits embedding.

isSubsettingPermittedback to summary
private boolean isSubsettingPermitted(TrueTypeFont ttf) throws IOException

Returns true if the fsType in the OS/2 table permits subsetting.

needsSubsetback to summary
public boolean needsSubset()

Returns true if the font needs to be subset.

subsetback to summary
public void subset() throws IOException

Implements org.apache.pdfbox.pdmodel.font.Subsetter.subset.

Doc from org.apache.pdfbox.pdmodel.font.Subsetter.subset.

Subset this font now.

Annotations
@Override
Exceptions
IOException:
if the font could not be read