Class TrueTypeEmbedder

    • 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 void buildFontFile2​(java.io.InputStream ttfStream)
                            throws java.io.IOException
        Throws:
        java.io.IOException
      • isEmbeddingPermitted

        private 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
      • getTrueTypeFont

        @Deprecated
        public TrueTypeFont getTrueTypeFont()
        Deprecated.
        Returns the FontBox font.
      • getFontDescriptor

        public PDFontDescriptor getFontDescriptor()
        Returns the font descriptor.
      • addToSubset

        public void addToSubset​(int codePoint)
        Description copied from interface: Subsetter
        Adds the given Unicode code point to this subset.
        Specified by:
        addToSubset in interface Subsetter
        Parameters:
        codePoint - Unicode code point
      • subset

        public void subset()
                    throws java.io.IOException
        Description copied from interface: Subsetter
        Subset this font now.
        Specified by:
        subset in interface Subsetter
        Throws:
        java.io.IOException - if the font could not be read
      • 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.IOException
        Rebuild 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.