org.extex.font.format.xtf.tables.gps
Class ClassDefTable

java.lang.Object
  extended by org.extex.font.format.xtf.tables.gps.ClassDefTable
All Implemented Interfaces:
XMLWriterConvertible
Direct Known Subclasses:
ClassDefTable.ClassDef1Table, ClassDefTable.ClassDef2Table

public abstract class ClassDefTable
extends java.lang.Object
implements XMLWriterConvertible

Class for a ClassDef table.

In OpenType Layout, index values identify glyphs. For efficiency and ease of representation, a font developer can group glyph indices to form glyph classes. Class assignments vary in meaning from one lookup subtable to another. For example, in the GSUB and GPOS tables, classes are used to describe glyph contexts. GDEF tables also use the idea of glyph classes.

Consider a substitution action that replaces only the lowercase ascender glyphs in a glyph string. To more easily describe the appropriate context for the substitution, the font developer might divide the font's lowercase glyphs into two classes, one that contains the ascenders and one that contains the glyphs without ascenders.

A font developer can assign any glyph to any class, each identified with an integer called a class value. A Class Definition table (ClassDef) groups glyph indices by class, beginning with Class 1, then Class 2, and so on. All glyphs not assigned to a class fall into Class 0. Within a given class definition table, each glyph in the font belongs to exactly one class.

The ClassDef table can have either of two formats: one that assigns a range of consecutive glyph indices to different classes, or one that puts groups of consecutive glyph indices into the same class.

Version:
$Revision: 6737 $
Author:
Michael Niedermair

Nested Class Summary
static class ClassDefTable.ClassDef1Table
          ClassDefTable for Format 1.
static class ClassDefTable.ClassDef2Table
          ClassDefTable for Format 2.
 
Field Summary
protected  java.util.Map<java.lang.Integer,java.lang.Integer> classMap
          The map for the classRangeRecord (to increase the search speed).
protected  int defNr
          class def number.
protected  int format
          The class format.
protected  XtfGlyphName xtfGlyph
          The glyph names.
 
Constructor Summary
ClassDefTable()
           
 
Method Summary
 void addClass0(int[] glyphs)
          Add glyphs in Class 0.
 int getClass(int glyph)
          Returns the class for the glyph or -1 if not found.
 int getFormat()
          Getter for format.
static ClassDefTable newInstance(RandomAccessR rar, XtfGlyphName xtfGlyph, int defNr)
          Returns a new instance of the ClassDefTable.
 void writeXML(XMLStreamWriter writer)
          Write the data to a XMLStreamWriter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

classMap

protected java.util.Map<java.lang.Integer,java.lang.Integer> classMap
The map for the classRangeRecord (to increase the search speed).


defNr

protected int defNr
class def number.


format

protected int format
The class format.


xtfGlyph

protected XtfGlyphName xtfGlyph
The glyph names.

Constructor Detail

ClassDefTable

public ClassDefTable()
Method Detail

newInstance

public static ClassDefTable newInstance(RandomAccessR rar,
                                        XtfGlyphName xtfGlyph,
                                        int defNr)
                                 throws java.io.IOException
Returns a new instance of the ClassDefTable.

Parameters:
rar - The input.
xtfGlyph - The glyph name.
defNr - The class def number.
Returns:
Returns a new instance of the ClassDefTable.
Throws:
java.io.IOException - if a IO-error occurred.

addClass0

public void addClass0(int[] glyphs)
Add glyphs in Class 0.

All glyphs not assigned to a class fall into Class 0.

Parameters:
glyphs - The glyphs (number) from the coverage list.

getClass

public int getClass(int glyph)
Returns the class for the glyph or -1 if not found.

Parameters:
glyph - The glyph number.
Returns:
Returns the class for the glyph or -1 if not found.

getFormat

public int getFormat()
Getter for format.

Returns:
the format

writeXML

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

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