Interface PDFontLike

    • Method Detail

      • getName

        java.lang.String getName()
        Returns the name of this font, either the PostScript "BaseName" or the Type 3 "Name".
      • getFontDescriptor

        PDFontDescriptor getFontDescriptor()
        Returns the font descriptor, may be null.
      • getFontMatrix

        Matrix getFontMatrix()
        Returns the font matrix, which represents the transformation from glyph space to text space.
      • getBoundingBox

        BoundingBox getBoundingBox()
                            throws java.io.IOException
        Returns the font's bounding box.
        Throws:
        java.io.IOException
      • getPositionVector

        Vector getPositionVector​(int code)
        Returns the position vector (v), in text space, for the given character. This represents the position of vertical origin relative to horizontal origin, for horizontal writing it will always be (0, 0). For vertical writing both x and y are set.
        Parameters:
        code - character code
        Returns:
        position vector
      • getHeight

        @Deprecated
        float getHeight​(int code)
                 throws java.io.IOException
        Deprecated.
        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 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
      • getWidth

        float getWidth​(int code)
                throws java.io.IOException
        Returns the advance width of the given character, in glyph space.

        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 instead. See the cyan rectangles in the DrawPrintTextLocations.java example to see this in action.

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

        boolean hasExplicitWidth​(int code)
                          throws java.io.IOException
        Returns true if the Font dictionary specifies an explicit width for the given glyph. This includes Width, W but not default widths entries.
        Parameters:
        code - character code
        Throws:
        java.io.IOException - if the font could not be read
      • getWidthFromFont

        float getWidthFromFont​(int code)
                        throws java.io.IOException
        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

        boolean isEmbedded()
        Returns true if the font file is embedded in the PDF.
      • isDamaged

        boolean isDamaged()
        Returns true if the embedded font file is damaged.
      • getAverageFontWidth

        float getAverageFontWidth()
        This will get the average font width for all characters.
        Returns:
        The width is in 1000 unit of text space, ie 333 or 777