Class IndentityGlyphMapper


  • public class IndentityGlyphMapper
    extends GlyphMapper
    A concrete subclass of GlyphMapper for the Identity-H & Identity-V maps input bytes -> cids is done with no mapping, just interpreting the bytes as big-endian shorts. Also supports mapping to GIDs via an embedded CIDToGIDMap

    Note that for fonts with CIDToGIDMaps, it might be tempting to provide a way to skip the CID step and just go from input bytes to GIDs. However, all the font metric info is based on CIDs, so we're always going to have to convert to CIDs no matter what.

    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean canHandleEncoding​(java.lang.String pdfEncodingName)  
      boolean isMultiByte()
      Returns true if the encoding consumes more than single byte for a character.
      int mapBytesToChars​(byte[] inbytes, int offset, int length, char[] outchars)
      The workhorse.
      int mapCharsToGIDs​(char[] cidbuffer, int ncids, int[] gidbuffer)
      Does the cid->gid mapping, if it knows how.
      int maximumOutputBufferSize​(byte[] inbytes, int offset, int length)
      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)
      For CID fonts that know how to map their cids directly into glyph indices.
      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

      • IndentityGlyphMapper

        public IndentityGlyphMapper​(java.util.Map fontDict,
                                    PDFFile srcfile)
    • Method Detail

      • canHandleEncoding

        public static boolean canHandleEncoding​(java.lang.String pdfEncodingName)
      • setCIDToGIDMap

        public void setCIDToGIDMap​(java.lang.Object mapobj)
        For CID fonts that know how to map their cids directly into glyph indices.
        Overrides:
        setCIDToGIDMap in class GlyphMapper
      • isMultiByte

        public boolean isMultiByte()
        Description copied from class: GlyphMapper
        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.
        Specified by:
        isMultiByte in class GlyphMapper
      • maximumOutputBufferSize

        public int maximumOutputBufferSize​(byte[] inbytes,
                                           int offset,
                                           int length)
        Description copied from class: GlyphMapper
        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.
        Specified by:
        maximumOutputBufferSize in class GlyphMapper
      • mapBytesToChars

        public int mapBytesToChars​(byte[] inbytes,
                                   int offset,
                                   int length,
                                   char[] outchars)
        Description copied from class: GlyphMapper
        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.
        Specified by:
        mapBytesToChars in class GlyphMapper
      • supportsCIDToGIDMapping

        public boolean supportsCIDToGIDMapping()
        Description copied from class: GlyphMapper
        Returns true if encoding knows how to convert to glyph indices.
        Overrides:
        supportsCIDToGIDMapping in class GlyphMapper
      • mapCharsToGIDs

        public int mapCharsToGIDs​(char[] cidbuffer,
                                  int ncids,
                                  int[] gidbuffer)
        Description copied from class: GlyphMapper
        Does the cid->gid mapping, if it knows how. Returns the total number of glyphs created.
        Overrides:
        mapCharsToGIDs in class GlyphMapper