Package org.apache.pdfbox.pdmodel.font
Class PDCIDFontType2Embedder
- java.lang.Object
-
- org.apache.pdfbox.pdmodel.font.TrueTypeEmbedder
-
- org.apache.pdfbox.pdmodel.font.PDCIDFontType2Embedder
-
- All Implemented Interfaces:
Subsetter
final class PDCIDFontType2Embedder extends TrueTypeEmbedder
Embedded PDCIDFontType2 builder. Helper class to populate a PDCIDFontType2 and its parent PDType0Font from a TTF.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classPDCIDFontType2Embedder.State
-
Field Summary
Fields Modifier and Type Field Description private COSDictionarycidFontprivate COSDictionarydictprivate PDDocumentdocumentprivate static org.apache.commons.logging.LogLOGprivate PDType0Fontparentprivate booleanvertical-
Fields inherited from class org.apache.pdfbox.pdmodel.font.TrueTypeEmbedder
cmapLookup, fontDescriptor, ttf
-
-
Constructor Summary
Constructors Constructor Description PDCIDFontType2Embedder(PDDocument document, COSDictionary dict, TrueTypeFont ttf, boolean embedSubset, PDType0Font parent, boolean vertical)Creates a new TrueType font embedder for the given TTF as a PDCIDFontType2.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidaddNameTag(java.lang.String tag)private voidbuildCIDSet(java.util.TreeMap<java.lang.Integer,java.lang.Integer> cidToGid)Builds the CIDSet entry, required by PDF/A.private voidbuildCIDToGIDMap(java.util.TreeMap<java.lang.Integer,java.lang.Integer> cidToGid)protected voidbuildSubset(java.io.InputStream ttfSubset, java.lang.String tag, java.util.Map<java.lang.Integer,java.lang.Integer> gidToCid)Rebuild a font subset.private voidbuildToUnicodeCMap(java.util.Map<java.lang.Integer,java.lang.Integer> newGIDToOldCID)private booleanbuildVerticalHeader(COSDictionary cidFont)private voidbuildVerticalMetrics(java.util.TreeMap<java.lang.Integer,java.lang.Integer> cidToGid)Builds vertical metrics with a custom CIDToGIDMap (for embedding font subset).private voidbuildVerticalMetrics(COSDictionary cidFont)Build vertical metrics with Identity CIDToGIDMap (for embedding full font).private voidbuildWidths(java.util.TreeMap<java.lang.Integer,java.lang.Integer> cidToGid)Builds widths with a custom CIDToGIDMap (for embedding font subset).private voidbuildWidths(COSDictionary cidFont)Build widths with Identity CIDToGIDMap (for embedding full font).private COSDictionarycreateCIDFont()PDCIDFontgetCIDFont()Returns the descendant CIDFont.private COSArraygetVerticalMetrics(int[] values)private COSArraygetWidths(int[] widths)private COSDictionarytoCIDSystemInfo(java.lang.String registry, java.lang.String ordering, int supplement)-
Methods inherited from class org.apache.pdfbox.pdmodel.font.TrueTypeEmbedder
addGlyphIds, addToSubset, buildFontFile2, getFontDescriptor, getTag, isEmbeddingPermitted, needsSubset, subset
-
-
-
-
Field Detail
-
LOG
private static final org.apache.commons.logging.Log LOG
-
document
private final PDDocument document
-
parent
private final PDType0Font parent
-
dict
private final COSDictionary dict
-
cidFont
private final COSDictionary cidFont
-
vertical
private final boolean vertical
-
-
Constructor Detail
-
PDCIDFontType2Embedder
PDCIDFontType2Embedder(PDDocument document, COSDictionary dict, TrueTypeFont ttf, boolean embedSubset, PDType0Font parent, boolean vertical) throws java.io.IOException
Creates a new TrueType font embedder for the given TTF as a PDCIDFontType2.- Parameters:
document- parent documentdict- font dictionaryttf- True Type Fontparent- parent Type 0 font- Throws:
java.io.IOException- if the TTF could not be read
-
-
Method Detail
-
buildSubset
protected 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.- Specified by:
buildSubsetin classTrueTypeEmbedder- Throws:
java.io.IOException
-
buildToUnicodeCMap
private void buildToUnicodeCMap(java.util.Map<java.lang.Integer,java.lang.Integer> newGIDToOldCID) throws java.io.IOException- Throws:
java.io.IOException
-
toCIDSystemInfo
private COSDictionary toCIDSystemInfo(java.lang.String registry, java.lang.String ordering, int supplement)
-
createCIDFont
private COSDictionary createCIDFont() throws java.io.IOException
- Throws:
java.io.IOException
-
addNameTag
private void addNameTag(java.lang.String tag)
-
buildCIDToGIDMap
private void buildCIDToGIDMap(java.util.TreeMap<java.lang.Integer,java.lang.Integer> cidToGid) throws java.io.IOException- Throws:
java.io.IOException
-
buildCIDSet
private void buildCIDSet(java.util.TreeMap<java.lang.Integer,java.lang.Integer> cidToGid) throws java.io.IOExceptionBuilds the CIDSet entry, required by PDF/A. This lists all CIDs in the font, including those that don't have a GID.- Throws:
java.io.IOException
-
buildWidths
private void buildWidths(java.util.TreeMap<java.lang.Integer,java.lang.Integer> cidToGid) throws java.io.IOExceptionBuilds widths with a custom CIDToGIDMap (for embedding font subset).- Throws:
java.io.IOException
-
buildVerticalHeader
private boolean buildVerticalHeader(COSDictionary cidFont) throws java.io.IOException
- Throws:
java.io.IOException
-
buildVerticalMetrics
private void buildVerticalMetrics(java.util.TreeMap<java.lang.Integer,java.lang.Integer> cidToGid) throws java.io.IOExceptionBuilds vertical metrics with a custom CIDToGIDMap (for embedding font subset).- Throws:
java.io.IOException
-
buildWidths
private void buildWidths(COSDictionary cidFont) throws java.io.IOException
Build widths with Identity CIDToGIDMap (for embedding full font).- Throws:
java.io.IOException
-
getWidths
private COSArray getWidths(int[] widths) throws java.io.IOException
- Throws:
java.io.IOException
-
buildVerticalMetrics
private void buildVerticalMetrics(COSDictionary cidFont) throws java.io.IOException
Build vertical metrics with Identity CIDToGIDMap (for embedding full font).- Throws:
java.io.IOException
-
getVerticalMetrics
private COSArray getVerticalMetrics(int[] values) throws java.io.IOException
- Throws:
java.io.IOException
-
getCIDFont
public PDCIDFont getCIDFont() throws java.io.IOException
Returns the descendant CIDFont.- Throws:
java.io.IOException
-
-