Class Type1CFont


  • public class Type1CFont
    extends OutlineFont
    A representation, with parser, of an Adobe Type 1C font.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      (package private) class  Type1CFont.Range
      A range.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) java.awt.geom.AffineTransform at  
      (package private) int charsetbase  
      (package private) int charstringbase  
      (package private) int charstringtype  
      (package private) java.lang.String[] chr2name  
      (package private) static int CMD  
      (package private) byte[] data  
      (package private) int[] encoding  
      (package private) int encodingbase  
      (package private) static int FLT  
      (package private) float fnum  
      (package private) java.lang.String fontname  
      (package private) int[] glyphnames  
      (package private) int gsubrbase  
      (package private) int gsubrsoffset  
      (package private) int lsubrbase  
      (package private) int lsubrsoffset  
      (package private) java.lang.String[] names  
      (package private) int nglyphs  
      (package private) int num  
      (package private) static int NUM  
      (package private) int pos  
      (package private) int privatebase  
      (package private) int privatesize  
      (package private) float[] stack  
      (package private) int stackptr  
      (package private) byte[] subrs  
      (package private) float[] temps  
      (package private) int type  
    • Constructor Summary

      Constructors 
      Constructor Description
      Type1CFont​(java.lang.String baseFont, PDFObject src, PDFFontDescriptor descriptor)
      create a new Type1CFont based on a font data stream and a descriptor
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private void buildAccentChar​(float x, float y, char b, char a, java.awt.geom.GeneralPath gp)
      build an accented character out of two pre-defined glyphs.
      int calcoffset​(int base)
      calculate an offset code for a dictionary.
      (package private) Type1CFont.Range getIndexEntry​(int index, int id)
      Get the range of a particular index in a dictionary.
      int getIndexSize​(int loc)
      get the size of the dictionary located within the stream at some offset.
      private int getNameIndex​(java.lang.String name)
      get the index of a particular name.
      protected java.awt.geom.GeneralPath getOutline​(char src, float width)
      Get a glyph outline by character code Note this method must always return an outline
      protected java.awt.geom.GeneralPath getOutline​(java.lang.String name, float width)
      Get a glyph outline by name
      java.lang.String getSID​(int id)
      get the name associated with an ID.
      int getTableLength​(int loc)
      return the number of entries in an Index table.
      private void parse()
      parse the font data.
      (package private) void parseGlyph​(Type1CFont.Range r, java.awt.geom.GeneralPath gp, FlPoint pt)
      parse a glyph defined in a particular range
      private void printData()
      a debug method for printing the data
      private int readByte()
      read the next byte from the stream
      private int readCommand​(boolean charstring)
      read a complete command.
      private void readDict​(Type1CFont.Range r)
      read a dictionary that exists within some range, parsing the entries within the dictionary.
      private void readEncodingData​(int base)
      parse information about the encoding of this file.
      void readFNum()
      read the next funky floating point number from the input stream.
      private java.awt.geom.GeneralPath readGlyph​(int base, int offset)
      Read the data for a glyph from the glyph table, and transform it based on the current transform.
      private void readGlyphNames​(int base)
      read the names of the glyphs.
      private int readInt​(int len)
      read an integer from the input stream
      private void readNames​(int base)
      read a list of names
      private int readNext​(boolean charstring)
      read the next decoded value from the stream
      private java.lang.String safe​(java.lang.String src)
      convert a string to one in which any non-printable bytes are replaced by "<###>" where ## is the value of the byte.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • chr2name

        java.lang.String[] chr2name
      • data

        byte[] data
      • pos

        int pos
      • subrs

        byte[] subrs
      • stack

        float[] stack
      • stackptr

        int stackptr
      • names

        java.lang.String[] names
      • glyphnames

        int[] glyphnames
      • encoding

        int[] encoding
      • fontname

        java.lang.String fontname
      • at

        java.awt.geom.AffineTransform at
      • num

        int num
      • fnum

        float fnum
      • type

        int type
      • CMD

        static int CMD
      • NUM

        static int NUM
      • FLT

        static int FLT
      • charstringtype

        int charstringtype
      • temps

        float[] temps
      • charsetbase

        int charsetbase
      • encodingbase

        int encodingbase
      • charstringbase

        int charstringbase
      • privatebase

        int privatebase
      • privatesize

        int privatesize
      • gsubrbase

        int gsubrbase
      • lsubrbase

        int lsubrbase
      • gsubrsoffset

        int gsubrsoffset
      • lsubrsoffset

        int lsubrsoffset
      • nglyphs

        int nglyphs
    • Constructor Detail

      • Type1CFont

        public Type1CFont​(java.lang.String baseFont,
                          PDFObject src,
                          PDFFontDescriptor descriptor)
                   throws java.io.IOException
        create a new Type1CFont based on a font data stream and a descriptor
        Parameters:
        baseFont - the postscript name of this font
        src - a stream containing the font
        descriptor - the descriptor for this font
        Throws:
        java.io.IOException
    • Method Detail

      • printData

        private void printData()
        a debug method for printing the data
      • readNext

        private int readNext​(boolean charstring)
        read the next decoded value from the stream
        Parameters:
        charstring - ????
      • readFNum

        public void readFNum()
        read the next funky floating point number from the input stream. value gets put into the fnum field.
      • readInt

        private int readInt​(int len)
        read an integer from the input stream
        Parameters:
        len - the number of bytes in the integer
        Returns:
        the integer
      • readByte

        private int readByte()
        read the next byte from the stream
        Returns:
        the byte
      • getIndexSize

        public int getIndexSize​(int loc)
        get the size of the dictionary located within the stream at some offset.
        Parameters:
        loc - the index of the start of the dictionary
        Returns:
        the size of the dictionary, in bytes.
      • getTableLength

        public int getTableLength​(int loc)
        return the number of entries in an Index table.
        Parameters:
        loc -
        Returns:
      • getIndexEntry

        Type1CFont.Range getIndexEntry​(int index,
                                       int id)
        Get the range of a particular index in a dictionary.
        Parameters:
        index - the start of the dictionary.
        id - the index of the entry in the dictionary
        Returns:
        a range describing the offsets of the start and end of the entry from the start of the file, not the dictionary
      • readDict

        private void readDict​(Type1CFont.Range r)
        read a dictionary that exists within some range, parsing the entries within the dictionary.
      • readCommand

        private int readCommand​(boolean charstring)
        read a complete command. this may involve several numbers which go onto a stack before an actual command is read.
        Parameters:
        charstring - ????
        Returns:
        the command. Some numbers may also be on the stack.
      • readEncodingData

        private void readEncodingData​(int base)
        parse information about the encoding of this file.
        Parameters:
        base - the start of the encoding data
      • readGlyphNames

        private void readGlyphNames​(int base)
        read the names of the glyphs.
        Parameters:
        base - the start of the glyph name table
      • readNames

        private void readNames​(int base)
        read a list of names
        Parameters:
        base - the start of the name table
      • parse

        private void parse()
                    throws java.io.IOException
        parse the font data.
        Parameters:
        encdif - a dictionary describing the encoding.
        Throws:
        java.io.IOException
      • getNameIndex

        private int getNameIndex​(java.lang.String name)
        get the index of a particular name. The name table starts with the standard names in FontSupport.stdNames, and is appended by any names in the name table from this font's dictionary.
      • safe

        private java.lang.String safe​(java.lang.String src)
        convert a string to one in which any non-printable bytes are replaced by "<###>" where ## is the value of the byte.
      • readGlyph

        private java.awt.geom.GeneralPath readGlyph​(int base,
                                                    int offset)
        Read the data for a glyph from the glyph table, and transform it based on the current transform.
        Parameters:
        base - the start of the glyph table
        offset - the index of this glyph in the glyph table
      • calcoffset

        public int calcoffset​(int base)
        calculate an offset code for a dictionary. Uses the count of entries to determine what the offset should be.
        Parameters:
        base - the index of the start of the dictionary
      • getSID

        public java.lang.String getSID​(int id)
        get the name associated with an ID.
        Parameters:
        id - the index of the name
        Returns:
        the name from the FontSupport.stdNames table augmented by the local name table
      • buildAccentChar

        private void buildAccentChar​(float x,
                                     float y,
                                     char b,
                                     char a,
                                     java.awt.geom.GeneralPath gp)
        build an accented character out of two pre-defined glyphs.
        Parameters:
        x - the x offset of the accent
        y - the y offset of the accent
        b - the index of the base glyph
        a - the index of the accent glyph
        gp - the GeneralPath into which the combined glyph will be written.
      • parseGlyph

        void parseGlyph​(Type1CFont.Range r,
                        java.awt.geom.GeneralPath gp,
                        FlPoint pt)
        parse a glyph defined in a particular range
        Parameters:
        r - the range of the glyph definition
        gp - a GeneralPath in which to store the glyph outline
        pt - a FlPoint representing the end of the current path
      • getOutline

        protected java.awt.geom.GeneralPath getOutline​(java.lang.String name,
                                                       float width)
        Get a glyph outline by name
        Specified by:
        getOutline in class OutlineFont
        Parameters:
        name - the name of the desired glyph
        Returns:
        the glyph outline, or null if unavailable
      • getOutline

        protected java.awt.geom.GeneralPath getOutline​(char src,
                                                       float width)
        Get a glyph outline by character code Note this method must always return an outline
        Specified by:
        getOutline in class OutlineFont
        Parameters:
        src - the character code of the desired glyph
        Returns:
        the glyph outline