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 class
PDCIDFontType2Embedder.State
-
Field Summary
Fields Modifier and Type Field Description private COSDictionary
cidFont
private COSDictionary
dict
private PDDocument
document
private static org.apache.commons.logging.Log
LOG
private PDType0Font
parent
private boolean
vertical
-
Fields inherited from class org.apache.pdfbox.pdmodel.font.TrueTypeEmbedder
cmap, 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 void
addNameTag(java.lang.String tag)
private void
buildCIDSet(java.util.Map<java.lang.Integer,java.lang.Integer> cidToGid)
Builds the CIDSet entry, required by PDF/A.private void
buildCIDToGIDMap(java.util.Map<java.lang.Integer,java.lang.Integer> cidToGid)
protected 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 void
buildToUnicodeCMap(java.util.Map<java.lang.Integer,java.lang.Integer> newGIDToOldCID)
private boolean
buildVerticalHeader(COSDictionary cidFont)
private void
buildVerticalMetrics(java.util.Map<java.lang.Integer,java.lang.Integer> cidToGid)
Builds vertical metrics with a custom CIDToGIDMap (for embedding font subset).private void
buildVerticalMetrics(COSDictionary cidFont)
Build vertical metrics with Identity CIDToGIDMap (for embedding full font).private void
buildWidths(java.util.Map<java.lang.Integer,java.lang.Integer> cidToGid)
Builds widths with a custom CIDToGIDMap (for embedding font subset).private void
buildWidths(COSDictionary cidFont)
Build widths with Identity CIDToGIDMap (for embedding full font).private COSDictionary
createCIDFont()
PDCIDFont
getCIDFont()
Returns the descendant CIDFont.private COSArray
getVerticalMetrics(int[] values)
private COSArray
getWidths(int[] widths)
private COSDictionary
toCIDSystemInfo(java.lang.String registry, java.lang.String ordering, int supplement)
-
Methods inherited from class org.apache.pdfbox.pdmodel.font.TrueTypeEmbedder
addToSubset, buildFontFile2, getFontDescriptor, getTag, getTrueTypeFont, 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.IOException
Rebuild a font subset.- Specified by:
buildSubset
in 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.Map<java.lang.Integer,java.lang.Integer> cidToGid) throws java.io.IOException
- Throws:
java.io.IOException
-
buildCIDSet
private void buildCIDSet(java.util.Map<java.lang.Integer,java.lang.Integer> cidToGid) throws java.io.IOException
Builds 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.Map<java.lang.Integer,java.lang.Integer> cidToGid) throws java.io.IOException
Builds 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.Map<java.lang.Integer,java.lang.Integer> cidToGid) throws java.io.IOException
Builds 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
-
-