Package com.ribs.pdf

Class GlyphMapper

java.lang.Object
com.ribs.pdf.GlyphMapper
Direct Known Subclasses:
IndentityGlyphMapper, LatinGlyphMapper

public abstract class GlyphMapper extends Object
  • Constructor Details

    • GlyphMapper

      public GlyphMapper(Map fontDict, PDFFile srcfile)
      Creates a new mapper for the font. For Latin fonts, the encodingDict is the dict pulled out of the pdf file (with /BaseFont & /Differences entries) more complex encoding dicts could contain cmaps or other info.
  • Method Details

    • canHandleEncoding

      public static boolean canHandleEncoding(String pdfEncodingName)
      Returns true if this subclass knows how to handle the given encoding
    • isMultiByte

      public abstract boolean isMultiByte()
      Returns true if the encoding consumes more than single byte for a character. Note that encodings that sometimes maps single bytes, but other times maps more than one, should always return true for this routine.
    • maximumOutputBufferSize

      public abstract int maximumOutputBufferSize(byte[] inbytes, int offset, int len)
      Quickly returns the maximum number of chars that could result from the conversion of inbytes bytes according to the encoding. A single byte encoding, like the latin ones, will take a single byte and convert it into a single char, so this routine would just return len. An encoding that takes 2 bytes and converts them to a char would return len/2, etc.
    • mapBytesToChars

      public abstract int mapBytesToChars(byte[] inbytes, int offset, int len, char[] outchars)
      The workhorse. Take an input buffer and convert everything. The output buffer should be allocated using the size from the above routine. The actual number of chars in the final output is returned.
    • supportsCIDToGIDMapping

      public boolean supportsCIDToGIDMapping()
      Returns true if encoding knows how to convert to glyph indices.
    • setCIDToGIDMap

      public void setCIDToGIDMap(Object mapobj)
      Sets the cid to glyph index map info. This object will will be interpreted as whatever format is appropriate for the particular glyphmapper.
    • mapCharsToGIDs

      public int mapCharsToGIDs(char[] cidbuffer, int numcids, int[] gidbuffer)
      Does the cid->gid mapping, if it knows how. Returns the total number of glyphs created.
    • createGlyphMapper

      public static GlyphMapper createGlyphMapper(Map fontDict, PDFFile srcfile)
      Search routine to find a GlyphMapper subclass
    • adobeGlyphNameToUnicode

      public static int adobeGlyphNameToUnicode(String name, Map fontDict)
      Maps a single glyph name string to a unicode value. This is an implementation of the algorithm described in http://partners.adobe.com/public/developer/opentype/index_glyph.html
    • main

      public static void main(String[] args)