Class PDCIDFontType0

    • Field Detail

      • LOG

        private static final org.apache.commons.logging.Log LOG
      • glyphHeights

        private final java.util.Map<java.lang.Integer,​java.lang.Float> glyphHeights
      • isEmbedded

        private final boolean isEmbedded
      • isDamaged

        private final boolean isDamaged
      • avgWidth

        private java.lang.Float avgWidth
      • fontMatrix

        private Matrix fontMatrix
      • fontMatrixTransform

        private final java.awt.geom.AffineTransform fontMatrixTransform
      • cid2gid

        private int[] cid2gid
    • Constructor Detail

      • PDCIDFontType0

        public PDCIDFontType0​(COSDictionary fontDictionary,
                              PDType0Font parent)
                       throws java.io.IOException
        Constructor.
        Parameters:
        fontDictionary - The font dictionary according to the PDF specification.
        parent - The parent font.
        Throws:
        java.io.IOException
    • Method Detail

      • getFontMatrix

        public final Matrix getFontMatrix()
        Description copied from interface: PDFontLike
        Returns the font matrix, which represents the transformation from glyph space to text space.
      • getBoundingBox

        public BoundingBox getBoundingBox()
        Description copied from interface: PDFontLike
        Returns the font's bounding box.
      • generateBoundingBox

        private BoundingBox generateBoundingBox()
      • getCFFFont

        public CFFFont getCFFFont()
        Returns the embedded CFF CIDFont, or null if the substitute is not a CFF font.
      • getFontBoxFont

        public FontBoxFont getFontBoxFont()
        Returns the embedded or substituted font.
      • getType2CharString

        public Type2CharString getType2CharString​(int cid)
                                           throws java.io.IOException
        Returns the Type 2 charstring for the given CID, or null if the substituted font does not contain Type 2 charstrings.
        Parameters:
        cid - CID
        Throws:
        java.io.IOException - if the charstring could not be read
      • getGlyphName

        private java.lang.String getGlyphName​(int code)
                                       throws java.io.IOException
        Returns the name of the glyph with the given character code. This is done by looking up the code in the parent font's ToUnicode map and generating a glyph name from that.
        Throws:
        java.io.IOException
      • getPath

        public java.awt.geom.GeneralPath getPath​(int code)
                                          throws java.io.IOException
        Description copied from interface: PDVectorFont
        Returns the glyph path for the given character code in a PDF.
        Parameters:
        code - character code in a PDF. Not to be confused with unicode.
        Throws:
        java.io.IOException - if the font could not be read
      • hasGlyph

        public boolean hasGlyph​(int code)
                         throws java.io.IOException
        Description copied from interface: PDVectorFont
        Returns true if this font contains a glyph for the given character code in a PDF.
        Parameters:
        code - character code in a PDF. Not to be confused with unicode.
        Throws:
        java.io.IOException
      • codeToCID

        public int codeToCID​(int code)
        Returns the CID for the given character code. If not found then CID 0 is returned.
        Specified by:
        codeToCID in class PDCIDFont
        Parameters:
        code - character code
        Returns:
        CID
      • codeToGID

        public int codeToGID​(int code)
        Description copied from class: PDCIDFont
        Returns the GID for the given character code.
        Specified by:
        codeToGID in class PDCIDFont
        Parameters:
        code - character code
        Returns:
        GID
      • encode

        public byte[] encode​(int unicode)
        Description copied from class: PDCIDFont
        Encodes the given Unicode code point for use in a PDF content stream. Content streams use a multi-byte encoding with 1 to 4 bytes.

        This method is called when embedding text in PDFs and when filling in fields.

        Specified by:
        encode in class PDCIDFont
        Parameters:
        unicode - Unicode code point.
        Returns:
        Array of 1 to 4 PDF content stream bytes.
      • getWidthFromFont

        public float getWidthFromFont​(int code)
                               throws java.io.IOException
        Description copied from interface: PDFontLike
        Returns the width of a glyph in the embedded font file.
        Parameters:
        code - character code
        Returns:
        width in glyph space
        Throws:
        java.io.IOException - if the font could not be read
      • isEmbedded

        public boolean isEmbedded()
        Description copied from interface: PDFontLike
        Returns true if the font file is embedded in the PDF.
      • isDamaged

        public boolean isDamaged()
        Description copied from interface: PDFontLike
        Returns true if the embedded font file is damaged.
      • getHeight

        public float getHeight​(int code)
                        throws java.io.IOException
        Description copied from interface: PDFontLike
        Returns the height of the given character, in glyph space. This can be expensive to calculate. Results are only approximate.

        Warning: This method is deprecated in PDFBox 2.0 because there is no meaningful value which it can return. The PDFontLike.getWidth(int) method returns the advance width of a glyph, but there is no corresponding advance height. The logical height of a character is the same for every character in a font, so if you want that, retrieve the font bbox's height. Otherwise if you want the visual bounds of the glyph then call getPath(..) on the appropriate PDFont subclass to retrieve the glyph outline as a GeneralPath. See the cyan rectangles in the DrawPrintTextLocations.java example to see this in action.

        Parameters:
        code - character code
        Throws:
        java.io.IOException
      • getAverageFontWidth

        public float getAverageFontWidth()
        Description copied from interface: PDFontLike
        This will get the average font width for all characters.
        Specified by:
        getAverageFontWidth in interface PDFontLike
        Overrides:
        getAverageFontWidth in class PDCIDFont
        Returns:
        The width is in 1000 unit of text space, ie 333 or 777
      • getAverageCharacterWidth

        private float getAverageCharacterWidth()