org.extex.font.format.xtf.tables
Class TtfTableCMAP.Format2

java.lang.Object
  extended by org.extex.font.format.xtf.tables.TtfTableCMAP.Format
      extended by org.extex.font.format.xtf.tables.TtfTableCMAP.Format2
All Implemented Interfaces:
XMLWriterConvertible
Enclosing class:
TtfTableCMAP

public class TtfTableCMAP.Format2
extends TtfTableCMAP.Format

The format 2 mapping subtable type is used for fonts containing Japanese, Chinese, or Korean characters. The code standards used in this table are supported on Macintosh systems in Asia.

These fonts contain a mixed 8/16-bit encoding, in which certain byte values are set aside to signal the first byte of a 2-byte character. These special values are also legal as the second byte of a 2-byte character.

Type Name Description
USHORT format Format number is set to 2.
USHORT length Length in bytes.
USHORT version Version number (starts at 0)
USHORT subHeaderKeys[256] Array that maps high bytes to subHeaders: value is subHeader index * 8.
4 words struct subHeaders[ ] Variable-length array of subHeader structures.
4 words-struct subHeaders[ ]
USHORT glyphIndexArray[ ] Variable-length array containing subarrays used for mapping the low byte of 2-byte characters.

A subHeader is structured as follows:

Type Name Description
USHORT firstCode First valid low byte for this subHeader.
USHORT entryCount Number of valid low bytes for this subHeader.
SHORT idDelta See text below.
USHORT idRangeOffset

The firstCode and entryCount values specify a subrange that begins at firstCode and has a length equal to the value of entryCount. This subrange stays within the 0–255 range of the byte being mapped. Bytes outside of this subrange are mapped to glyph index 0 (missing glyph).The offset of the byte within this subrange is then used as index into a corresponding subarray of glyphIndexArray. This subarray is also of length entryCount. The value of the idRangeOffset is the number of bytes past the actual location of the idRangeOffset word where the glyphIndexArray element corresponding to firstCode appears.

Finally, if the value obtained from the subarray is not 0 (which indicates the missing glyph), you should add idDelta to it in order to get the glyphIndex. The value idDelta permits the same subarray to be used for several different subheaders. The idDelta arithmetic is modulo 65536.


Method Summary
 int mapCharCode(int charCode)
          map char code.
 void writeXML(XMLStreamWriter writer)
          Write the data to a XMLStreamWriter.
 
Methods inherited from class org.extex.font.format.xtf.tables.TtfTableCMAP.Format
addAttributes, getFormat, getLength, getVersion, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

mapCharCode

public int mapCharCode(int charCode)
map char code.

Specified by:
mapCharCode in class TtfTableCMAP.Format
Parameters:
charCode - the charcode
Returns:
Returns the map char code
See Also:
TtfTableCMAP.Format.mapCharCode(int)

writeXML

public void writeXML(XMLStreamWriter writer)
              throws java.io.IOException
Write the data to a XMLStreamWriter.

Parameters:
writer - the XML-Writer
Throws:
java.io.IOException - if an IO-error occurs.
See Also:
XMLWriterConvertible.writeXML( org.extex.util.xml.XMLStreamWriter)