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

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

public class TtfTableHDMX
extends AbstractXtfTable
implements XtfTable, XMLWriterConvertible

The table 'hdmx' (Horizontal Device Metrics).

The hdmx table relates to OpenType fonts with TrueType outlines. The Horizontal Device Metrics table stores integer advance widths scaled to particular pixel sizes. This allows the font manager to build integer width tables without calling the scaler for each glyph. Typically this table contains only selected screen sizes. This table is sorted by pixel size. The checksum for this table applies to both subtables listed.

Note that for non-square pixel grids, the character width (in pixels) will be used to determine which device record to use. For example, a 12 point character on a device with a resolution of 72x96 would be 12 pixels high and 16 pixels wide. The hdmx device record for 16 pixel characters would be used.

If bit 4 of the flag field in the 'head' table is not set, then it is assumed that the font scales linearly; in this case an 'hdmx' table is not necessary and should not be built. If bit 4 of the flag field is set, then one or more glyphs in the font are assumed to scale nonlinearly. In this case, performance can be improved by including the 'hdmx' table with one or more important DeviceRecord's for important sizes.

hdmx Header

Type Name Description
USHORT version Table version number (0)
SHORT numRecords Number of device records.
LONG sizeDeviceRecord Size of a device record, long aligned.
DeviceRecord records[numRecords] Array of device records.

Device Record

<
Type Name Description
BYTE pixelSize Pixel size for following widths (as ppem).
BYTE maxWidth Maximum width.
BYTE Widths[numGlyphs] Array of widths (numGlyphs is from the 'maxp' table).

Version:
$Revision: 6604 $
Author:
Michael Niedermair

Nested Class Summary
 class TtfTableHDMX.DeviceRecord
          the device record
 
Constructor Summary
TtfTableHDMX(XtfTableMap tablemap, XtfTableDirectory.Entry de, RandomAccessR rar)
          Create a new object
 
Method Summary
 TtfTableHDMX.DeviceRecord[] getDeviceRecord()
          Returns the deviceRecord.
 int getNumRecords()
          Returns the numRecords.
 java.lang.String getShortcut()
          Returns the table shortcut.
 int getSizeDeviceRecord()
          Returns the sizeDeviceRecord.
 int getType()
          Get the table type, as a table directory value.
 int getVersion()
          Returns the version.
 void init()
          Initialize the table.
 void writeXML(XMLStreamWriter writer)
          Write the data to a XMLStreamWriter.
 
Methods inherited from class org.extex.font.format.xtf.tables.AbstractXtfTable
getGlyphName, getInitOrder, getTableMap, 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
 

Constructor Detail

TtfTableHDMX

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

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

getDeviceRecord

public TtfTableHDMX.DeviceRecord[] getDeviceRecord()
Returns the deviceRecord.

Returns:
Returns the deviceRecord.

getNumRecords

public int getNumRecords()
Returns the numRecords.

Returns:
Returns the numRecords.

getShortcut

public java.lang.String getShortcut()
Returns the table shortcut.

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

getSizeDeviceRecord

public int getSizeDeviceRecord()
Returns the sizeDeviceRecord.

Returns:
Returns the sizeDeviceRecord.

getType

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

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

getVersion

public int getVersion()
Returns the version.

Returns:
Returns the version.

init

public void init()
          throws java.io.IOException
Initialize the table.

Specified by:
init in interface XtfTable
Overrides:
init in class AbstractXtfTable
Throws:
java.io.IOException - if a IO-error is occurred.
See Also:
AbstractXtfTable.init()

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)