Class PDCIDFont

  • Direct Known Subclasses:
    PDType0Font

    public class PDCIDFont
    extends PDFont
    Class represents CIDFont on PD level.
    Author:
    Sergey Shemyakov
    • Field Detail

      • cMap

        protected CMap cMap
    • Constructor Detail

      • PDCIDFont

        public PDCIDFont​(COSDictionary dictionary,
                         CMap cMap)
        Constructor from COSDictionary and CMap with code -> cid mapping.
        Parameters:
        dictionary - is COSDictionary of CIDFont.
        cMap - is CMap object containing mapping code -> cid.
      • PDCIDFont

        public PDCIDFont​(COSDictionary dictionary,
                         CMap cMap,
                         FontProgram fontProgram,
                         boolean isFontParsed)
        Constructor that sets font program for this CIDFont. Can be used when font program should not be parsed twice and is already read.
        Parameters:
        dictionary - is COSDictionary of CIDFont.
        cMap - is CMap object containing mapping code -> cid.
        fontProgram - is embedded font program associated with this CIDFont.
        isFontParsed - is true if embedded font program has been already parsed.
    • Method Detail

      • getCIDSet

        public COSStream getCIDSet()
        Returns:
        a stream identifying which CIDs are present in the CIDFont file.
      • getCIDToGIDMap

        public COSObject getCIDToGIDMap()
        Returns:
        a specification of the mapping from CIDs to glyph indices if CIDFont is a Type 2 CIDFont.
      • getWidth

        public Double getWidth​(int code)
        Gets width for glyph with given code in this font.
        Overrides:
        getWidth in class PDFont
        Parameters:
        code - is code of glyph.
        Returns:
        width for glyph with given code as specified in Widths array.
      • getDefaultWidth

        public Double getDefaultWidth()
        Overrides:
        getDefaultWidth in class PDFont
        Returns:
        default width for this font as specified in font descriptor.
      • readCode

        public int readCode​(InputStream stream)
                     throws IOException
        Method reads next character code from stream according to font data. It can contain from 1 to 4 bytes.
        Overrides:
        readCode in class PDFont
        Parameters:
        stream - is stream with raw data.
        Returns:
        next character code read.
        Throws:
        IOException - if reading fails.
      • getWidthFromProgram

        public float getWidthFromProgram​(int code)
        Description copied from class: PDFont
        Gets width of given code from font program.
        Specified by:
        getWidthFromProgram in class PDFont
        Parameters:
        code - is code of character in strings to display.
        Returns:
        width of glyph for this code.
      • glyphIsPresent

        public boolean glyphIsPresent​(int code)
        Description copied from class: PDFont
        Checks if glyph for given code is present in this font.
        Specified by:
        glyphIsPresent in class PDFont
        Parameters:
        code - is code for glyph in this font.
        Returns:
        true if glyph is present.
      • getCIDSystemInfo

        public PDCIDSystemInfo getCIDSystemInfo()
        Returns:
        CID System Info object for this CIDFont.