org.extex.font.format.xtf.tables
Class OtfTableCFF

java.lang.Object
  extended by org.extex.font.format.xtf.tables.AbstractXtfTable
      extended by org.extex.font.format.xtf.tables.OtfTableCFF
All Implemented Interfaces:
XtfGlyphName, XtfTable, XMLWriterConvertible

public class OtfTableCFF
extends AbstractXtfTable
implements XtfTable, XMLWriterConvertible

The 'CFF' - PostScript font program.

This table contains a compact representation of a PostScript Type 1, or CIDFont and is structured according to Adobe Technical Note #5176: " The Compact BaseFont Format Specification" and Adobe Technical Note #5177: "Type 2 Charstring Format".

CFF Data Types

Name Range Description
Card8 0 255 1-byte unsigned number
Card16 0 65535 2-byte unsigned number
Offset varies 1, 2, 3, or 4 byte offset (specified by OffSize field)
OffSize 1 - 4 1-byte unsigned number specifies the size of an Offset field or fields
SID 0 - 64999 2-byte string identifier

CFF Data Layout

Entry Comments
Header -
Name INDEX -
Top DICT INDEX -
String INDEX ->/td>
Global Subr INDEX -
Encodings -
Charsets -
FDSelect CIDFonts only
CharStrings INDEX per-font
BaseFont DICT INDEX per-font, CIDFonts only
Private DICT per-font
Local Subr INDEX per-font or per-Private DICT for CIDFonts
Copyright and Trademark Notices -/td>

Version:
$Revision: 6748 $
Author:
Michael Niedermair

Constructor Summary
OtfTableCFF(XtfTableMap tablemap, XtfTableDirectory.Entry de, RandomAccessR rar)
          Create a new object
 
Method Summary
 CffFont getFont(int number)
          Returns the font.
 int getHdrSize()
          Returns the hdrSize.
 int getNumGlyphs()
          Returns the number of glyphs
 java.lang.String getShortcut()
          Returns the table shortcut.
 java.lang.String getStringIndex(int sid)
          Returns the String for the SID.
 int getType()
          Get the table type, as a table directory value.
 int getVersionmajor()
          Returns the version major.
 int getVersionminor()
          Returns the version minor.
 int mapGlyphNameToGlyphPos(java.lang.String glyphname, int fontnumber)
          Map the glyph name to the glyph position.
 java.lang.String mapGlyphPosToGlyphName(int glyphpos, int fontnumber)
          Map the glyph position to the name of the glyph.
 byte[] readDataFromIndex(int start, int end, RandomAccessR rar)
          An INDEX is an array of variable-sized objects.
 int[] readOffsets(RandomAccessR rar)
          Read the offsets.
 void writeXML(XMLStreamWriter writer)
          Write the data to a XMLStreamWriter.
 
Methods inherited from class org.extex.font.format.xtf.tables.AbstractXtfTable
getGlyphName, getInitOrder, getTableMap, init, writeStartElement
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.extex.font.format.xtf.tables.XtfTable
getInitOrder, getTableMap, init
 

Constructor Detail

OtfTableCFF

public OtfTableCFF(XtfTableMap tablemap,
                   XtfTableDirectory.Entry de,
                   RandomAccessR rar)
            throws java.io.IOException
Create a new object

Parameters:
tablemap - the table map
de - entry
rar - input
Throws:
java.io.IOException - if an IO-error occurs
Method Detail

getFont

public CffFont getFont(int number)
Returns the font.

Parameters:
number - The font numer.
Returns:
Returns the font.

getHdrSize

public int getHdrSize()
Returns the hdrSize.

Returns:
Returns the hdrSize.

getNumGlyphs

public int getNumGlyphs()
Returns the number of glyphs

Returns:
Returns the number of glyphs

getShortcut

public java.lang.String getShortcut()
Description copied from interface: XtfTable
Returns the table shortcut.

Specified by:
getShortcut in interface XtfTable
Returns:
Returns the table shortcut.
See Also:
XtfTable.getShortcut()

getStringIndex

public java.lang.String getStringIndex(int sid)
Returns the String for the SID. First, test if SID is in standard range then fetch from internal table, otherwise, fetch string from the String INDEX using a value of (SID-nStdStrings) as the index.

Parameters:
sid - the SID for the string.
Returns:
Returns the String or null, if not found.

getType

public int getType()
Get the table type, as a table directory value.

Specified by:
getType in interface XtfTable
Returns:
Returns the table type

getVersionmajor

public int getVersionmajor()
Returns the version major.

Returns:
Returns the version major.

getVersionminor

public int getVersionminor()
Returns the version minor.

Returns:
Returns the version minor.

mapGlyphNameToGlyphPos

public int mapGlyphNameToGlyphPos(java.lang.String glyphname,
                                  int fontnumber)
Map the glyph name to the glyph position. If the glyph name not found, -1 is returned.

Parameters:
glyphname - The glyph name
fontnumber - The fontnumber.
Returns:
Returns the position of the glyph name.

mapGlyphPosToGlyphName

public java.lang.String mapGlyphPosToGlyphName(int glyphpos,
                                               int fontnumber)
Map the glyph position to the name of the glyph.

Parameters:
glyphpos - The glyph position
fontnumber - The font number.
Returns:
Returns the name of the glpyh or null, if not found.

readDataFromIndex

public byte[] readDataFromIndex(int start,
                                int end,
                                RandomAccessR rar)
                         throws java.io.IOException
An INDEX is an array of variable-sized objects.

It comprises a header, an offset array, and object data. The offset array specifies offsets within the object data. An object is retrieved by indexing the offset array and fetching the object at the specified offset. The object's length can be determined by subtracting its offset from the next offset in the offset array. An additional offset is added at the end of the offset array so the length of the last object may be determined.

Type Name Description
Card16 count Number of objects stored in INDEX. An empty INDEX is represented by a count field with a 0 value and no additional fields. Thus, the total size of an empty INDEX is 2 bytes.
OffSize offSize Offset array element size
Offset offset [count+1] Offset array (from byte preceding object data). Offsets in the offset array are relative to the byte that precedes the object data. Therefore the first element of the offset array is always 1. (This ensures that every object has a corresponding offset which is always nonzero and permits the efficient implementation of dynamic object loading.)
Card8 data [<varies>] Object data
Offsets in the offset array are relative to the byte that precedes the object data. Therefore the first element of the offset array is always 1. (This ensures that every object has a corresponding offset which is always nonzero and permits the efficient implementation of dynamic object loading.) An empty INDEX is represented by a count field with a 0 value and no additional fields. Thus, the total size of an empty INDEX is 2 bytes.

Parameters:
start - the start offset
end - the end offset
rar - the input
Returns:
Returns the data
Throws:
java.io.IOException - if an IO-error occurs

readOffsets

public int[] readOffsets(RandomAccessR rar)
                  throws java.io.IOException
Read the offsets.

Parameters:
rar - The input.
Returns:
Returns the offsets.
Throws:
java.io.IOException - if a IO-error occurred.

writeXML

public void writeXML(XMLStreamWriter writer)
              throws java.io.IOException
Description copied from interface: XMLWriterConvertible
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)