Class GlyphMapper

    • Constructor Summary

      Constructors 
      Constructor Description
      GlyphMapper​(java.util.Map fontDict, PDFFile srcfile)
      Creates a new mapper for the font.
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      static int adobeGlyphNameToUnicode​(java.lang.String name, java.util.Map fontDict)
      Maps a single glyph name string to a unicode value.
      static boolean canHandleEncoding​(java.lang.String pdfEncodingName)
      Returns true if this subclass knows how to handle the given encoding
      static GlyphMapper createGlyphMapper​(java.util.Map fontDict, PDFFile srcfile)
      Search routine to find a GlyphMapper subclass
      abstract boolean isMultiByte()
      Returns true if the encoding consumes more than single byte for a character.
      static void main​(java.lang.String[] args)  
      abstract int mapBytesToChars​(byte[] inbytes, int offset, int len, char[] outchars)
      The workhorse.
      int mapCharsToGIDs​(char[] cidbuffer, int numcids, int[] gidbuffer)
      Does the cid->gid mapping, if it knows how.
      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.
      void setCIDToGIDMap​(java.lang.Object mapobj)
      Sets the cid to glyph index map info.
      boolean supportsCIDToGIDMapping()
      Returns true if encoding knows how to convert to glyph indices.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • GlyphMapper

        public GlyphMapper​(java.util.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 Detail

      • canHandleEncoding

        public static boolean canHandleEncoding​(java.lang.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​(java.lang.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​(java.util.Map fontDict,
                                                    PDFFile srcfile)
        Search routine to find a GlyphMapper subclass
      • adobeGlyphNameToUnicode

        public static int adobeGlyphNameToUnicode​(java.lang.String name,
                                                  java.util.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​(java.lang.String[] args)