Class OpenTypeFontProgram

java.lang.Object
org.verapdf.pd.font.opentype.OpenTypeFontProgram
All Implemented Interfaces:
FontProgram

public class OpenTypeFontProgram extends Object implements FontProgram
Represents OpenType font program.
Author:
Sergey Shemyakov
  • Constructor Details

    • OpenTypeFontProgram

      public OpenTypeFontProgram(ASInputStream source, boolean isCFF, boolean isCIDFontType2, boolean isSymbolic, COSObject encoding, CMap externalCMap, boolean isSubset, COSObject cidToGIDMap, COSKey key) throws IOException
      Constructor from stream, containing font data, and encoding details.
      Parameters:
      source - is stream containing font data.
      isSymbolic - is true if font is marked as symbolic.
      encoding - is value of /Encoding in font dictionary.
      Throws:
      IOException
  • Method Details

    • getWidth

      public float getWidth(int code)
      Returns width of glyph for given character code.
      Specified by:
      getWidth in interface FontProgram
      Parameters:
      code - is code for glyph.
      Returns:
      width of corresponding glyph or -1 if glyph is not found.
    • getWidth

      public float getWidth(String glyphName)
      Returns width of glyph for given glyph name.
      Specified by:
      getWidth in interface FontProgram
      Parameters:
      glyphName - is name for glyph.
      Returns:
      width of corresponding glyph or -1 if glyph is not found.
    • containsCode

      public boolean containsCode(int code)
      Checks if font contains character with given code.
      Specified by:
      containsCode in interface FontProgram
      Parameters:
      code - is character code.
      Returns:
      true if font contains character with given code.
    • containsGlyph

      public boolean containsGlyph(String glyphName)
      Description copied from interface: FontProgram
      Checks if this font program has glyph for given glyph name.
      Specified by:
      containsGlyph in interface FontProgram
      Parameters:
      glyphName - is the name of glyph.
      Returns:
      true if this font program has glyph for given name.
    • containsCID

      public boolean containsCID(int cid)
      Description copied from interface: FontProgram
      Method works only for fonts where cid notation is used.
      Specified by:
      containsCID in interface FontProgram
      Returns:
      true if font a is cid font and contains given cid.
    • getGlyphName

      public String getGlyphName(int code)
      Description copied from interface: FontProgram
      Returns glyph name for glyph with given code.
      Specified by:
      getGlyphName in interface FontProgram
      Parameters:
      code - is code of glyph.
      Returns:
      glyph name.
    • isAttemptedParsing

      public boolean isAttemptedParsing()
      Specified by:
      isAttemptedParsing in interface FontProgram
      Returns:
      true if font parsing has been attempted.
    • isSuccessfulParsing

      public boolean isSuccessfulParsing()
      Specified by:
      isSuccessfulParsing in interface FontProgram
      Returns:
      true if font was successfully parsed.
    • parseFont

      public void parseFont() throws IOException
      This method does parsing of font, after it all the data needed should be extracted.
      Specified by:
      parseFont in interface FontProgram
      Throws:
      IOException - if error in font parsing occurs.
    • getFont

      public FontProgram getFont()
      Returns:
      CFF font or TrueType font, represented by this OpenType font.
    • getFontProgramResource

      public ASFileStreamCloser getFontProgramResource()
      Specified by:
      getFontProgramResource in interface FontProgram
      Returns:
      file stream closer that handles the closing of font program stream or null if stream is memory stream.
    • getWeight

      public String getWeight()
      Specified by:
      getWeight in interface FontProgram
    • getAscent

      public Double getAscent()
      Specified by:
      getAscent in interface FontProgram
    • getDescent

      public Double getDescent()
      Specified by:
      getDescent in interface FontProgram
    • getCIDList

      public List<Integer> getCIDList()
      Specified by:
      getCIDList in interface FontProgram