Class Type1CFont


public class Type1CFont extends OutlineFont
A representation, with parser, of an Adobe Type 1C font.
  • Field Details

    • chr2name

      String[] chr2name
    • data

      byte[] data
    • pos

      int pos
    • subrs

      byte[] subrs
    • stack

      float[] stack
    • stackptr

      int stackptr
    • names

      String[] names
    • glyphnames

      int[] glyphnames
    • encoding

      int[] encoding
    • fontname

      String fontname
    • 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 Details

    • Type1CFont

      public Type1CFont(String baseFont, PDFObject src, PDFFontDescriptor descriptor) throws 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:
      IOException
  • Method Details

    • 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 IOException
      parse the font data.
      Parameters:
      encdif - a dictionary describing the encoding.
      Throws:
      IOException
    • getNameIndex

      private int getNameIndex(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 String safe(String src)
      convert a string to one in which any non-printable bytes are replaced by "invalid input: '<'###>" where ## is the value of the byte.
    • readGlyph

      private 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 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, 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, 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 GeneralPath getOutline(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 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