Class 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.
    • Field Detail

      • LOG

        private static final org.apache.commons.logging.Log LOG
      • 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 document
        dict - font dictionary
        ttf - True Type Font
        parent - 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 class TrueTypeEmbedder
        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