Class PDType1CFont

All Implemented Interfaces:
COSObjectable

public class PDType1CFont extends PDSimpleFont
This class represents a CFF/Type2 Font (aka Type1C Font).
Author:
Villu Ruusmann
  • Constructor Details

    • PDType1CFont

      public PDType1CFont(COSDictionary fontDictionary) throws IOException
      Constructor.
      Parameters:
      fontDictionary - the corresponding dictionary
      Throws:
      IOException
  • Method Details

    • encode

      public String encode(byte[] bytes, int offset, int length) throws IOException
      This will perform the encoding of a character if needed.
      Overrides:
      encode in class PDFont
      Parameters:
      bytes - The character to encode.
      offset - The offset into the array to get the data
      length - The number of bytes to read.
      Returns:
      The value of the encoded character.
      Throws:
      IOException - If there is an error during the encoding.
    • encodeToCID

      public int encodeToCID(byte[] bytes, int offset, int length)
      Overrides:
      encodeToCID in class PDFont
    • getFontWidth

      public float getFontWidth(byte[] bytes, int offset, int length) throws IOException
      This will get the font width for a character.
      Overrides:
      getFontWidth in class PDSimpleFont
      Parameters:
      bytes - The character code to get the width for.
      offset - The offset into the array.
      length - The length of the data.
      Returns:
      The width is in 1000 unit of text space, ie 333 or 777
      Throws:
      IOException - If an error occurs while parsing.
    • getFontHeight

      public float getFontHeight(byte[] bytes, int offset, int length) throws IOException
      This will get the font height for a character.
      Overrides:
      getFontHeight in class PDSimpleFont
      Parameters:
      bytes - The character code to get the width for.
      offset - The offset into the array.
      length - The length of the data.
      Returns:
      The width is in 1000 unit of text space, ie 333 or 777
      Throws:
      IOException - If an error occurs while parsing.
    • getStringWidth

      public float getStringWidth(String string) throws IOException
      This will get the width of this string for this font.
      Overrides:
      getStringWidth in class PDFont
      Parameters:
      string - The string to get the width of.
      Returns:
      The width of the string in 1000 units of text space, ie 333 567...
      Throws:
      IOException - If there is an error getting the width information.
    • getAverageFontWidth

      public float getAverageFontWidth() throws IOException
      This will get the average font width for all characters.
      Overrides:
      getAverageFontWidth in class PDSimpleFont
      Returns:
      The width is in 1000 unit of text space, ie 333 or 777
      Throws:
      IOException - If an error occurs while parsing.
    • getFontBoundingBox

      public PDRectangle getFontBoundingBox() throws IOException
      This will get the fonts bounding box.
      Overrides:
      getFontBoundingBox in class PDSimpleFont
      Returns:
      The fonts bouding box.
      Throws:
      IOException - If there is an error getting the bounding box.
    • getFontMatrix

      public PDMatrix getFontMatrix()
      This will get the matrix that is used to transform glyph space to text space. By default there are 1000 glyph units to 1 text space unit, but type3 fonts can use any value. Note:If this is a type3 font then it can be modified via the PDType3Font.setFontMatrix, otherwise this is a read-only property.
      Overrides:
      getFontMatrix in class PDFont
      Returns:
      The matrix to transform from glyph space to text space.
    • getawtFont

      public Font getawtFont() throws IOException
      Looks up, creates, returns the AWT Font.
      Overrides:
      getawtFont in class PDSimpleFont
      Returns:
      returns the awt font to bes used for rendering
      Throws:
      IOException - if something went wrong.
    • clear

      public void clear()
      Description copied from class: PDFont
      Calling this will release all cached information.
      Overrides:
      clear in class PDFont