Class CmapSubtable

  • All Implemented Interfaces:
    CmapLookup

    public class CmapSubtable
    extends java.lang.Object
    implements CmapLookup
    A "cmap" subtable.
    Author:
    Ben Litchfield
    • Constructor Summary

      Constructors 
      Constructor Description
      CmapSubtable()  
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      java.lang.Integer getCharacterCode​(int gid)
      Deprecated.
      the mapping may be ambiguous, see getCharCodes(int).
      java.util.List<java.lang.Integer> getCharCodes​(int gid)
      Returns all possible character codes for the given gid, or null if there is none.
      int getGlyphId​(int characterCode)
      Returns the GlyphId linked with the given character code.
      int getPlatformEncodingId()  
      int getPlatformId()  
      void initData​(org.apache.fontbox.ttf.TTFDataStream data)
      This will read the required data from the stream.
      void initSubtable​(CmapTable cmap, int numGlyphs, org.apache.fontbox.ttf.TTFDataStream data)
      This will read the required data from the stream.
      protected void processSubtype0​(org.apache.fontbox.ttf.TTFDataStream data)
      Initialize the CMapEntry when it is a subtype 0.
      protected void processSubtype10​(org.apache.fontbox.ttf.TTFDataStream data, int numGlyphs)
      Reads a format 10 subtable.
      protected void processSubtype12​(org.apache.fontbox.ttf.TTFDataStream data, int numGlyphs)
      Reads a format 12 subtable.
      protected void processSubtype13​(org.apache.fontbox.ttf.TTFDataStream data, int numGlyphs)
      Reads a format 13 subtable.
      protected void processSubtype14​(org.apache.fontbox.ttf.TTFDataStream data, int numGlyphs)
      Reads a format 14 subtable.
      protected void processSubtype2​(org.apache.fontbox.ttf.TTFDataStream data, int numGlyphs)
      Read a format 2 subtable.
      protected void processSubtype4​(org.apache.fontbox.ttf.TTFDataStream data, int numGlyphs)
      Reads a format 4 subtable.
      protected void processSubtype6​(org.apache.fontbox.ttf.TTFDataStream data, int numGlyphs)
      Reads a format 6 subtable.
      protected void processSubtype8​(org.apache.fontbox.ttf.TTFDataStream data, int numGlyphs)
      Reads a format 8 subtable.
      void setPlatformEncodingId​(int platformEncodingIdValue)  
      void setPlatformId​(int platformIdValue)  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

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

      • CmapSubtable

        public CmapSubtable()
    • Method Detail

      • initData

        public void initData​(org.apache.fontbox.ttf.TTFDataStream data)
                      throws java.io.IOException
        This will read the required data from the stream.
        Parameters:
        data - The stream to read the data from.
        Throws:
        java.io.IOException - If there is an error reading the data.
      • initSubtable

        public void initSubtable​(CmapTable cmap,
                                 int numGlyphs,
                                 org.apache.fontbox.ttf.TTFDataStream data)
                          throws java.io.IOException
        This will read the required data from the stream.
        Parameters:
        cmap - the CMAP this encoding belongs to.
        numGlyphs - number of glyphs.
        data - The stream to read the data from.
        Throws:
        java.io.IOException - If there is an error reading the data.
      • processSubtype8

        protected void processSubtype8​(org.apache.fontbox.ttf.TTFDataStream data,
                                       int numGlyphs)
                                throws java.io.IOException
        Reads a format 8 subtable.
        Parameters:
        data - the data stream of the to be parsed ttf font
        numGlyphs - number of glyphs to be read
        Throws:
        java.io.IOException - If there is an error parsing the true type font.
      • processSubtype10

        protected void processSubtype10​(org.apache.fontbox.ttf.TTFDataStream data,
                                        int numGlyphs)
                                 throws java.io.IOException
        Reads a format 10 subtable.
        Parameters:
        data - the data stream of the to be parsed ttf font
        numGlyphs - number of glyphs to be read
        Throws:
        java.io.IOException - If there is an error parsing the true type font.
      • processSubtype12

        protected void processSubtype12​(org.apache.fontbox.ttf.TTFDataStream data,
                                        int numGlyphs)
                                 throws java.io.IOException
        Reads a format 12 subtable.
        Parameters:
        data - the data stream of the to be parsed ttf font
        numGlyphs - number of glyphs to be read
        Throws:
        java.io.IOException - If there is an error parsing the true type font.
      • processSubtype13

        protected void processSubtype13​(org.apache.fontbox.ttf.TTFDataStream data,
                                        int numGlyphs)
                                 throws java.io.IOException
        Reads a format 13 subtable.
        Parameters:
        data - the data stream of the to be parsed ttf font
        numGlyphs - number of glyphs to be read
        Throws:
        java.io.IOException - If there is an error parsing the true type font.
      • processSubtype14

        protected void processSubtype14​(org.apache.fontbox.ttf.TTFDataStream data,
                                        int numGlyphs)
                                 throws java.io.IOException
        Reads a format 14 subtable.
        Parameters:
        data - the data stream of the to be parsed ttf font
        numGlyphs - number of glyphs to be read
        Throws:
        java.io.IOException - If there is an error parsing the true type font.
      • processSubtype6

        protected void processSubtype6​(org.apache.fontbox.ttf.TTFDataStream data,
                                       int numGlyphs)
                                throws java.io.IOException
        Reads a format 6 subtable.
        Parameters:
        data - the data stream of the to be parsed ttf font
        numGlyphs - number of glyphs to be read
        Throws:
        java.io.IOException - If there is an error parsing the true type font.
      • processSubtype4

        protected void processSubtype4​(org.apache.fontbox.ttf.TTFDataStream data,
                                       int numGlyphs)
                                throws java.io.IOException
        Reads a format 4 subtable.
        Parameters:
        data - the data stream of the to be parsed ttf font
        numGlyphs - number of glyphs to be read
        Throws:
        java.io.IOException - If there is an error parsing the true type font.
      • processSubtype2

        protected void processSubtype2​(org.apache.fontbox.ttf.TTFDataStream data,
                                       int numGlyphs)
                                throws java.io.IOException
        Read a format 2 subtable.
        Parameters:
        data - the data stream of the to be parsed ttf font
        numGlyphs - number of glyphs to be read
        Throws:
        java.io.IOException - If there is an error parsing the true type font.
      • processSubtype0

        protected void processSubtype0​(org.apache.fontbox.ttf.TTFDataStream data)
                                throws java.io.IOException
        Initialize the CMapEntry when it is a subtype 0.
        Parameters:
        data - the data stream of the to be parsed ttf font
        Throws:
        java.io.IOException - If there is an error parsing the true type font.
      • getPlatformEncodingId

        public int getPlatformEncodingId()
        Returns:
        Returns the platformEncodingId.
      • setPlatformEncodingId

        public void setPlatformEncodingId​(int platformEncodingIdValue)
        Parameters:
        platformEncodingIdValue - The platformEncodingId to set.
      • getPlatformId

        public int getPlatformId()
        Returns:
        Returns the platformId.
      • setPlatformId

        public void setPlatformId​(int platformIdValue)
        Parameters:
        platformIdValue - The platformId to set.
      • getGlyphId

        public int getGlyphId​(int characterCode)
        Returns the GlyphId linked with the given character code.
        Specified by:
        getGlyphId in interface CmapLookup
        Parameters:
        characterCode - the given character code to be mapped
        Returns:
        glyphId the corresponding glyph id for the given character code
      • getCharacterCode

        public java.lang.Integer getCharacterCode​(int gid)
        Deprecated.
        the mapping may be ambiguous, see getCharCodes(int). The first mapped value is returned by default.
        Returns the character code for the given GID, or null if there is none.
        Parameters:
        gid - glyph id
        Returns:
        character code
      • getCharCodes

        public java.util.List<java.lang.Integer> getCharCodes​(int gid)
        Returns all possible character codes for the given gid, or null if there is none.
        Specified by:
        getCharCodes in interface CmapLookup
        Parameters:
        gid - glyph id
        Returns:
        a list with all character codes the given gid maps to
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object