Class PFMFile


  • public class PFMFile
    extends java.lang.Object
    This class represents a PFM file (or parts of it) as a Java object.
    • Constructor Summary

      Constructors 
      Constructor Description
      PFMFile()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getCapHeight()
      Returns the CapHeight parameter for the font (height of uppercase H).
      short getCharSet()
      Returns the charset used for the font.
      java.lang.String getCharSetName()
      Returns the charset of the font as a string.
      int getCharWidth​(short which)
      Returns the width of a character
      short getFirstChar()
      Returns the number of the character that defines the first entry in the widths list.
      int getFlags()
      Returns the characteristics flags for the font as needed for a PDF font descriptor (See PDF specs).
      int[] getFontBBox()
      Returns the bounding box for the font.
      boolean getIsProportional()
      Tells whether the font has proportional character spacing.
      int getItalicAngle()
      Returns the italic angle of the font.
      java.util.Map<java.lang.Integer,​java.util.Map<java.lang.Integer,​java.lang.Integer>> getKerning()
      Return the kerning table.
      short getLastChar()
      Returns the number of the character that defines the last entry in the widths list.
      int getLowerCaseAscent()
      Returns the LowerCaseAscent parameter for the font (height of lowercase d).
      int getLowerCaseDescent()
      Returns the LowerCaseDescent parameter for the font (height of lowercase p).
      java.lang.String getPostscriptName()
      Returns the Postscript name of the font.
      int getStemV()
      Returns the width of the dominant vertical stems of the font.
      java.lang.String getWindowsName()
      Returns the Windows name of the font.
      int getXHeight()
      Returns the XHeight parameter for the font (height of lowercase x).
      boolean isNonSymbolic()
      Indicates whether the font is non-symbolic (Font uses the Adobe standard Latin character set or a subset of it).
      void load​(java.io.InputStream inStream)
      Parses a PFM file
      private void loadExtension​(PFMInputStream inStream)
      Parses the extension part of the PFM file.
      private void loadExtentTable​(PFMInputStream inStream)
      Parses the extent table of the PFM file.
      private void loadExtMetrics​(PFMInputStream inStream)
      Parses the extended metrics part of the PFM file.
      private void loadHeader​(PFMInputStream inStream)
      Parses the header of the PFM file.
      private void loadKernPairs​(PFMInputStream inStream)
      Parses the kernPairs part of the pfm file
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • windowsName

        private java.lang.String windowsName
      • postscriptName

        private java.lang.String postscriptName
      • dfItalic

        private short dfItalic
      • dfCharSet

        private short dfCharSet
      • dfPitchAndFamily

        private short dfPitchAndFamily
      • dfAvgWidth

        private int dfAvgWidth
      • dfMaxWidth

        private int dfMaxWidth
      • dfMinWidth

        private int dfMinWidth
      • dfFirstChar

        private short dfFirstChar
      • dfLastChar

        private short dfLastChar
      • etmCapHeight

        private int etmCapHeight
      • etmXHeight

        private int etmXHeight
      • etmLowerCaseAscent

        private int etmLowerCaseAscent
      • etmLowerCaseDescent

        private int etmLowerCaseDescent
      • extentTable

        private int[] extentTable
      • kerningTab

        private java.util.Map<java.lang.Integer,​java.util.Map<java.lang.Integer,​java.lang.Integer>> kerningTab
      • log

        protected org.apache.commons.logging.Log log
        logging instance
    • Constructor Detail

      • PFMFile

        public PFMFile()
    • Method Detail

      • load

        public void load​(java.io.InputStream inStream)
                  throws java.io.IOException
        Parses a PFM file
        Parameters:
        inStream - The stream from which to read the PFM file.
        Throws:
        java.io.IOException - In case of an I/O problem
      • loadHeader

        private void loadHeader​(PFMInputStream inStream)
                         throws java.io.IOException
        Parses the header of the PFM file.
        Parameters:
        inStream - The stream from which to read the PFM file.
        Throws:
        java.io.IOException - In case of an I/O problem
      • loadExtension

        private void loadExtension​(PFMInputStream inStream)
                            throws java.io.IOException
        Parses the extension part of the PFM file.
        Parameters:
        inStream - The stream from which to read the PFM file.
        Throws:
        java.io.IOException
      • loadKernPairs

        private void loadKernPairs​(PFMInputStream inStream)
                            throws java.io.IOException
        Parses the kernPairs part of the pfm file
        Parameters:
        inStream - The stream from which to read the PFM file.
        Throws:
        java.io.IOException
      • loadExtMetrics

        private void loadExtMetrics​(PFMInputStream inStream)
                             throws java.io.IOException
        Parses the extended metrics part of the PFM file.
        Parameters:
        inStream - The stream from which to read the PFM file.
        Throws:
        java.io.IOException
      • loadExtentTable

        private void loadExtentTable​(PFMInputStream inStream)
                              throws java.io.IOException
        Parses the extent table of the PFM file.
        Parameters:
        inStream - The stream from which to read the PFM file.
        Throws:
        java.io.IOException
      • getWindowsName

        public java.lang.String getWindowsName()
        Returns the Windows name of the font.
        Returns:
        The Windows name.
      • getKerning

        public java.util.Map<java.lang.Integer,​java.util.Map<java.lang.Integer,​java.lang.Integer>> getKerning()
        Return the kerning table. The kerning table is a Map with strings with glyphnames as keys, containing Maps as value. The value map contains a glyph name string key and an Integer value
        Returns:
        A Map containing the kerning table
      • getPostscriptName

        public java.lang.String getPostscriptName()
        Returns the Postscript name of the font.
        Returns:
        The Postscript name.
      • getCharSet

        public short getCharSet()
        Returns the charset used for the font.
        Returns:
        The charset (0=WinAnsi).
      • getCharSetName

        public java.lang.String getCharSetName()
        Returns the charset of the font as a string.
        Returns:
        The name of the charset.
      • getFirstChar

        public short getFirstChar()
        Returns the number of the character that defines the first entry in the widths list.
        Returns:
        The number of the first character.
      • getLastChar

        public short getLastChar()
        Returns the number of the character that defines the last entry in the widths list.
        Returns:
        The number of the last character.
      • getCapHeight

        public int getCapHeight()
        Returns the CapHeight parameter for the font (height of uppercase H).
        Returns:
        The CapHeight parameter.
      • getXHeight

        public int getXHeight()
        Returns the XHeight parameter for the font (height of lowercase x).
        Returns:
        The CapHeight parameter.
      • getLowerCaseAscent

        public int getLowerCaseAscent()
        Returns the LowerCaseAscent parameter for the font (height of lowercase d).
        Returns:
        The LowerCaseAscent parameter.
      • getLowerCaseDescent

        public int getLowerCaseDescent()
        Returns the LowerCaseDescent parameter for the font (height of lowercase p).
        Returns:
        The LowerCaseDescent parameter.
      • getIsProportional

        public boolean getIsProportional()
        Tells whether the font has proportional character spacing.
        Returns:
        ex. true for Times, false for Courier.
      • getFontBBox

        public int[] getFontBBox()
        Returns the bounding box for the font. Note: this value is just an approximation, it does not really exist in the PFM file.
        Returns:
        The calculated Font BBox.
      • isNonSymbolic

        public boolean isNonSymbolic()
        Indicates whether the font is non-symbolic (Font uses the Adobe standard Latin character set or a subset of it).
        Returns:
        true if the font is non-symbolic
      • getFlags

        public int getFlags()
        Returns the characteristics flags for the font as needed for a PDF font descriptor (See PDF specs).
        Returns:
        The characteristics flags.
      • getStemV

        public int getStemV()
        Returns the width of the dominant vertical stems of the font. Note: this value is just an approximation, it does not really exist in the PFM file.
        Returns:
        The vertical stem width.
      • getItalicAngle

        public int getItalicAngle()
        Returns the italic angle of the font. Note: this value is just an approximation, it does not really exist in the PFM file.
        Returns:
        The italic angle.
      • getCharWidth

        public int getCharWidth​(short which)
        Returns the width of a character
        Parameters:
        which - The number of the character for which the width is requested.
        Returns:
        The width of a character.