org.extex.font.format.xtf
Class XtfReader

java.lang.Object
  extended by org.extex.font.format.xtf.XtfReader
All Implemented Interfaces:
XMLWriterConvertible

public class XtfReader
extends java.lang.Object
implements XMLWriterConvertible

Reader for a TrueType / OpenType font.

Version:
$Revision: 7274 $
Author:
Michael Niedermair

Field Summary
static int ACNT
          Accent attachment.
static int AVAR
          Axis variation.
static int BASE
          Baseline data.
static int BDAT
          Bitmap data.
static int BLOC
          Bitmap location.
static int BSLN
          Baseline table.
static int CFF
          Compact font format (Type1 font).
static int CMAP
          Character to glyph mapping.
static int CVAR
          CVT variation.
static int CVT
          Control value table.
static int DSIG
          Digital signature.
static int EBDT
          Embedded bitmap data.
static int EBLC
          Embedded bitmap location.
static int EBSC
          Embedded bitmap scaling.
static java.lang.String EXTEX_TRACE_FONT_FILES
          The field EXTEX_TRACE_FONT_FILES.
static int FDSC
          BaseFont descriptors.
static int FEAT
          Feature name.
static int FMTX
          BaseFont metrics.
static int FPGM
          BaseFont program.
static int FVAR
          BaseFont variation.
static int GASP
          Grid-fitting and scan conversion procedure.
static int GDEF
          Glyph definition.
static int GLYF
          Glyph data.
static int GPOS
          Glyph positioning.
static int GSUB
          Glyph substitution.
static int GVAR
          Glyph variation.
static int HDMX
          Horizontal device metrics.
static int HEAD
          BaseFont header.
static int HHEA
          Horizontal metrics header.
static int HMTX
          Horizontal metrics.
static int JSTF
          Justification.
static int JUST
          Justification.
static int KERN
          Kerning.
static int LCAR
          Ligature caret.
static int LOCA
          Index to location.
static int LTSH
          Linear threshold.
static int MAXP
          Maximum profile.
static int MMFX
          Multiple master font metrics.
static int MMSD
          Multiple master supplementary data.
static int MORT
          Glyph metamorphosis.
static int NAME
          Naming table.
static int OS_2
          OS/2 and Windows specific metrics.
static org.extex.font.format.xtf.XtfReader.Type OTF
          OTF.
static int PCLT
          PCL 5 data.
static int POST
          PostScript Information.
static int PREP
          CVT preprogram.
static int PROP
          Glyph properties.
static int TRAK
          Tracking.
static org.extex.font.format.xtf.XtfReader.Type TTF
          TTF.
static int TYP1
          Adobe Type 1 font data.
static int VDMX
          Vertical device metrics.
static int VHEA
          Vertical metrics header.
static int VMTX
          Vertical metrics.
 
Constructor Summary
XtfReader(java.io.File file)
          Create a new object.
XtfReader(java.io.File file, java.util.logging.Logger logger)
          Create a new object.
XtfReader(java.io.InputStream iostream)
          Create a new object.
XtfReader(java.io.InputStream iostream, java.util.logging.Logger logger)
          Create a new object.
XtfReader(RandomAccessR rar)
          Create a new object.
XtfReader(RandomAccessR rar, java.util.logging.Logger logger)
          Create a new object.
XtfReader(java.lang.String filename)
          Create a new object.
XtfReader(java.lang.String filename, java.util.logging.Logger logger)
          Create a new object.
 
Method Summary
static java.util.Date convertDate(long value)
          Convert the internal long date format to a Date.
static java.lang.String convertIntToBinaryString(int value)
          Convert a int value in a binary string.
static java.lang.String convertIntToHexString(int value)
          Convert a int value in a hex string.
static float convertVersion(int value)
          Convert a Fixed value (Version).
 int getAscent()
          Returns the ascent.
 int[] getBoundingBox()
          Returns the BoundingBox.
 TtfTableCMAP getCmapTable()
          Returns the cmap table.
 int getDescent()
          Returns the descent.
 byte[] getFontData()
          Returns the data of the font.
 java.lang.String getFontFamilyName()
          Returns the font family name.
 XtfGlyph getGlyph(int i)
          Returns the glyph.
 TtfTableHEAD getHeadTable()
          Returns the head table.
 TtfTableHHEA getHheaTable()
          Returns the hhea table.
 TtfTableHMTX getHmtxTable()
          Returns the hmtx table.
 int getItalicAngle()
          Returns the italic angle.
 TtfTableLOCA getLocaTable()
          Returns the loca table.
 TtfTableMAXP getMaxpTable()
          Returns the os2 table.
 TtfTableNAME getNameTable()
          Returns the maxp table.
 int getNumberOfGlyphs()
          Returns the number of glyphs.
 TtfTableOS2 getOS2Table()
          Returns the os2 table.
 TtfTablePOST getPostTable()
          Returns the post table.
 XtfTable getTable(int tabletype)
          Return the table with the special type.
 XtfTableDirectory getTableDirectory()
          Returns the table directory.
 org.extex.font.format.xtf.XtfReader.Type getType()
          Returns the font type.
 int getUnderlinePos()
          Return the underline position.
 int getUnderlineThickness()
          Return the underline thickness.
 int getUnitsPerEm()
          Returns the units per em.
 boolean hasGlyph(java.lang.String glyphname, int fontnumber)
          Check, if the font has the glpyh.
 XtfBoundingBox mapCharCodeToBB(int charCode, int fontnumber, short platformId, short encodingId)
          Returns the bounding box for the char by using the platform and encoding.
 XtfBoundingBox mapCharCodeToBB(java.lang.String glypname, int fontnumber, short platformId, short encodingId)
          Returns the glyph bounding box for the char by using the platform and encoding.
 java.lang.String mapCharCodeToGlyphname(int charCode, int fontnumber, short platformId, short encodingId)
          Returns the glyph name for the char by using the platform and encoding.
 int mapCharCodetoKerning(int charcodeLeft, int charcodeRigth, int fontnumber, short platformId, short encodingId)
          Returns the kerning for the two chars.
 int mapCharCodetoLigature(int charcodeLeft, int charcodeRigth, java.util.List<java.lang.String> feature, java.lang.String language, int fontnumber, short platformId, short encodingId)
          Returns the ligature for the two chars.
 int mapCharCodeToWidth(int charCode, int fontnumber, short platformId, short encodingId)
          Returns the glyph width for the char by using the platform and encoding.
 int mapCharCodeToWidth(java.lang.String glyphname, int fontnumber, short platformId, short encodingId)
          Returns the glyph width for the char by using the platform and encoding.
 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

ACNT

public static final int ACNT
Accent attachment. Table tag "acnt" in the Open Type Specification.

See Also:
Constant Field Values

AVAR

public static final int AVAR
Axis variation. Table tag "avar" in the Open Type Specification.

See Also:
Constant Field Values

BASE

public static final int BASE
Baseline data. Table tag "BASE" in the Open Type Specification.

See Also:
Constant Field Values

BDAT

public static final int BDAT
Bitmap data. Table tag "bdat" in the Open Type Specification.

See Also:
Constant Field Values

BLOC

public static final int BLOC
Bitmap location. Table tag "bloc" in the Open Type Specification.

See Also:
Constant Field Values

BSLN

public static final int BSLN
Baseline table. Table tag "bsln" in the Open Type Specification.

See Also:
Constant Field Values

CFF

public static final int CFF
Compact font format (Type1 font). Table tag "CFF " in the Open Type Specification.

See Also:
Constant Field Values

CMAP

public static final int CMAP
Character to glyph mapping. (TTF required) Table tag "cmap" in the Open Type Specification.

See Also:
Constant Field Values

CVAR

public static final int CVAR
CVT variation. Table tag "cvar" in the Open Type Specification.

See Also:
Constant Field Values

CVT

public static final int CVT
Control value table. (TTF optional) Table tag "cvt " in the Open Type Specification.

See Also:
Constant Field Values

DSIG

public static final int DSIG
Digital signature. Table tag "DSIG" in the Open Type Specification.

See Also:
Constant Field Values

EBDT

public static final int EBDT
Embedded bitmap data. (TTF optional) Table tag "EBDT" in the Open Type Specification.

See Also:
Constant Field Values

EBLC

public static final int EBLC
Embedded bitmap location. (TTF optional) Table tag "EBLC" in the Open Type Specification.

See Also:
Constant Field Values

EBSC

public static final int EBSC
Embedded bitmap scaling. (TTF optional) Table tag "EBSC" in the Open Type Specification.

See Also:
Constant Field Values

EXTEX_TRACE_FONT_FILES

public static final java.lang.String EXTEX_TRACE_FONT_FILES
The field EXTEX_TRACE_FONT_FILES.

See Also:
Constant Field Values

FDSC

public static final int FDSC
BaseFont descriptors. Table tag "fdsc" in the Open Type Specification.

See Also:
Constant Field Values

FEAT

public static final int FEAT
Feature name. Table tag "feat" in the Open Type Specification.

See Also:
Constant Field Values

FMTX

public static final int FMTX
BaseFont metrics. Table tag "fmtx" in the Open Type Specification.

See Also:
Constant Field Values

FPGM

public static final int FPGM
BaseFont program. (TTF optional) Table tag "fpgm" in the Open Type Specification.

See Also:
Constant Field Values

FVAR

public static final int FVAR
BaseFont variation. Table tag "fvar" in the Open Type Specification.

See Also:
Constant Field Values

GASP

public static final int GASP
Grid-fitting and scan conversion procedure. (TTF optional) Table tag "gasp" in the Open Type Specification.

See Also:
Constant Field Values

GDEF

public static final int GDEF
Glyph definition. Table tag "GDEF" in the Open Type Specification.

See Also:
Constant Field Values

GLYF

public static final int GLYF
Glyph data. (TTF required) Table tag "glyf" in the Open Type Specification.

See Also:
Constant Field Values

GPOS

public static final int GPOS
Glyph positioning. Table tag "GPOS" in the Open Type Specification.

See Also:
Constant Field Values

GSUB

public static final int GSUB
Glyph substitution. Table tag "GSUB" in the Open Type Specification.

See Also:
Constant Field Values

GVAR

public static final int GVAR
Glyph variation. Table tag "gvar" in the Open Type Specification.

See Also:
Constant Field Values

HDMX

public static final int HDMX
Horizontal device metrics. (TTF optional) Table tag "hdmx" in the Open Type Specification.

See Also:
Constant Field Values

HEAD

public static final int HEAD
BaseFont header. (TTF required) Table tag "head" in the Open Type Specification.

See Also:
Constant Field Values

HHEA

public static final int HHEA
Horizontal metrics header. (TTF required) Table tag "hhea" in the Open Type Specification.

See Also:
Constant Field Values

HMTX

public static final int HMTX
Horizontal metrics. (TTF required) Table tag "hmtx" in the Open Type Specification.

See Also:
Constant Field Values

JSTF

public static final int JSTF
Justification. Table tag "JSTF" in the Open Type Specification.

See Also:
Constant Field Values

JUST

public static final int JUST
Justification. Table tag "just" in the Open Type Specification.

See Also:
Constant Field Values

KERN

public static final int KERN
Kerning. (TTF optional) Table tag "kern" in the Open Type Specification.

See Also:
Constant Field Values

LCAR

public static final int LCAR
Ligature caret. Table tag "lcar" in the Open Type Specification.

See Also:
Constant Field Values

LOCA

public static final int LOCA
Index to location. (TTF required) Table tag "loca" in the Open Type Specification.

See Also:
Constant Field Values

LTSH

public static final int LTSH
Linear threshold. (TTF optional) Table tag "LTSH" in the Open Type Specification.

See Also:
Constant Field Values

MAXP

public static final int MAXP
Maximum profile. (TTF required) Table tag "maxp" in the Open Type Specification.

See Also:
Constant Field Values

MMFX

public static final int MMFX
Multiple master font metrics. Table tag "MMFX" in the Open Type Specification.

See Also:
Constant Field Values

MMSD

public static final int MMSD
Multiple master supplementary data. Table tag "MMSD" in the Open Type Specification.

See Also:
Constant Field Values

MORT

public static final int MORT
Glyph metamorphosis. Table tag "mort" in the Open Type Specification.

See Also:
Constant Field Values

NAME

public static final int NAME
Naming table. (TTF required) Table tag "name" in the Open Type Specification.

See Also:
Constant Field Values

OS_2

public static final int OS_2
OS/2 and Windows specific metrics. (TTF required) Table tag "OS/2" in the Open Type Specification.

See Also:
Constant Field Values

OTF

public static final org.extex.font.format.xtf.XtfReader.Type OTF
OTF.


PCLT

public static final int PCLT
PCL 5 data. (TTF optional) Table tag "PCLT" in the Open Type Specification.

See Also:
Constant Field Values

POST

public static final int POST
PostScript Information. (TTF required) Table tag "post" in the Open Type Specification.

See Also:
Constant Field Values

PREP

public static final int PREP
CVT preprogram. (TTF optional) Table tag "prep" in the Open Type Specification.

See Also:
Constant Field Values

PROP

public static final int PROP
Glyph properties. Table tag "prop" in the Open Type Specification.

See Also:
Constant Field Values

TRAK

public static final int TRAK
Tracking. Table tag "trak" in the Open Type Specification.

See Also:
Constant Field Values

TTF

public static final org.extex.font.format.xtf.XtfReader.Type TTF
TTF.


TYP1

public static final int TYP1
Adobe Type 1 font data. Table tag "typ1" in the Open Type Specification.

See Also:
Constant Field Values

VDMX

public static final int VDMX
Vertical device metrics. (TTF optional) Table tag "VDMX" in the Open Type Specification.

See Also:
Constant Field Values

VHEA

public static final int VHEA
Vertical metrics header. (TTF optional) Table tag "vhea" in the Open Type Specification.

See Also:
Constant Field Values

VMTX

public static final int VMTX
Vertical metrics. (TTF optional) Table tag "vmtx" in the Open Type Specification.

See Also:
Constant Field Values
Constructor Detail

XtfReader

public XtfReader(java.io.File file)
          throws java.io.IOException
Create a new object.

Parameters:
file - The file for input.
Throws:
java.io.IOException - if an IO-error occurs

XtfReader

public XtfReader(java.io.File file,
                 java.util.logging.Logger logger)
          throws java.io.IOException
Create a new object.

Parameters:
file - The file for input.
logger - The logger.
Throws:
java.io.IOException - if an IO-error occurs

XtfReader

public XtfReader(java.io.InputStream iostream)
          throws java.io.IOException
Create a new object.

Parameters:
iostream - The stream for input.
Throws:
java.io.IOException - if an IO-error occurs

XtfReader

public XtfReader(java.io.InputStream iostream,
                 java.util.logging.Logger logger)
          throws java.io.IOException
Create a new object.

Parameters:
iostream - The stream for input.
logger - The logger.
Throws:
java.io.IOException - if an IO-error occurs

XtfReader

public XtfReader(RandomAccessR rar)
          throws java.io.IOException
Create a new object.

Parameters:
rar - The input.
Throws:
java.io.IOException - if an IO-error occurs

XtfReader

public XtfReader(RandomAccessR rar,
                 java.util.logging.Logger logger)
          throws java.io.IOException
Create a new object.

Parameters:
rar - The input.
logger - The logger.
Throws:
java.io.IOException - if an IO-error occurs

XtfReader

public XtfReader(java.lang.String filename)
          throws java.io.IOException
Create a new object.

Parameters:
filename - The file name for input.
Throws:
java.io.IOException - if an IO-error occurs

XtfReader

public XtfReader(java.lang.String filename,
                 java.util.logging.Logger logger)
          throws java.io.IOException
Create a new object.

Parameters:
filename - The file name for input.
logger - The logger.
Throws:
java.io.IOException - if an IO-error occurs
Method Detail

convertDate

public static java.util.Date convertDate(long value)
Convert the internal long date format to a Date.

Calculate the difference between the original Mac epoch (1904) to the epoch on this machine.

Parameters:
value - the long format (mac)
Returns:
Returns the calculate Date

convertIntToBinaryString

public static java.lang.String convertIntToBinaryString(int value)
Convert a int value in a binary string.

Parameters:
value - the int value
Returns:
Returns the binary string

convertIntToHexString

public static java.lang.String convertIntToHexString(int value)
Convert a int value in a hex string.

Parameters:
value - the int value
Returns:
Returns the hex string

convertVersion

public static float convertVersion(int value)
Convert a Fixed value (Version).

Parameters:
value - the fixed value
Returns:
Returns the float-value

getAscent

public int getAscent()
Returns the ascent.

Returns:
Returns the ascent

getBoundingBox

public int[] getBoundingBox()
Returns the BoundingBox.

0 xmin

1 ymin

2 xmax

3 ymax

Returns:
Returns the BoundingBox.

getCmapTable

public TtfTableCMAP getCmapTable()
Returns the cmap table.

Returns:
Returns the cmap table

getDescent

public int getDescent()
Returns the descent.

Returns:
Returns the descent

getFontData

public byte[] getFontData()
Returns the data of the font.

Returns:
the data of the font.

getFontFamilyName

public java.lang.String getFontFamilyName()
Returns the font family name.

Returns:
Returns the font family name.

getGlyph

public XtfGlyph getGlyph(int i)
Returns the glyph.

Parameters:
i - glyph number
Returns:
Returns the glyph

getHeadTable

public TtfTableHEAD getHeadTable()
Returns the head table.

Returns:
Returns the head table

getHheaTable

public TtfTableHHEA getHheaTable()
Returns the hhea table.

Returns:
Returns the hhea table

getHmtxTable

public TtfTableHMTX getHmtxTable()
Returns the hmtx table.

Returns:
Returns the hmtx table

getItalicAngle

public int getItalicAngle()
Returns the italic angle.

Returns:
Returns the italic angle.

getLocaTable

public TtfTableLOCA getLocaTable()
Returns the loca table.

Returns:
Returns the loca table

getMaxpTable

public TtfTableMAXP getMaxpTable()
Returns the os2 table.

Returns:
Returns the os2 table

getNameTable

public TtfTableNAME getNameTable()
Returns the maxp table.

Returns:
Returns the maxp table

getNumberOfGlyphs

public int getNumberOfGlyphs()
Returns the number of glyphs.

Returns:
Returns the number of glyphs.

getOS2Table

public TtfTableOS2 getOS2Table()
Returns the os2 table.

Returns:
Returns the os2 table

getPostTable

public TtfTablePOST getPostTable()
Returns the post table.

Returns:
Returns the post table

getTable

public XtfTable getTable(int tabletype)
Return the table with the special type.

Parameters:
tabletype - the table type
Returns:
Returns the table

getTableDirectory

public XtfTableDirectory getTableDirectory()
Returns the table directory.

Returns:
Returns the table directory

getType

public org.extex.font.format.xtf.XtfReader.Type getType()
Returns the font type.

Returns:
Returns the font type

getUnderlinePos

public int getUnderlinePos()
Return the underline position.

Returns:
Return the underline position.

getUnderlineThickness

public int getUnderlineThickness()
Return the underline thickness.

Returns:
Return the underline thickness.

getUnitsPerEm

public int getUnitsPerEm()
Returns the units per em.

Returns:
Returns the units per em.

hasGlyph

public boolean hasGlyph(java.lang.String glyphname,
                        int fontnumber)
Check, if the font has the glpyh.

Parameters:
glyphname - The glyph name.
fontnumber - The font number.
Returns:
Returns true, if the font has the glyph.

mapCharCodeToBB

public XtfBoundingBox mapCharCodeToBB(int charCode,
                                      int fontnumber,
                                      short platformId,
                                      short encodingId)
Returns the bounding box for the char by using the platform and encoding. If no char is found, null be returned.

Parameters:
charCode - The charCode.
fontnumber - The font number.
platformId - The platform id.
encodingId - The encoding id.
Returns:
Returns the glyph bounding box for the char.

mapCharCodeToBB

public XtfBoundingBox mapCharCodeToBB(java.lang.String glypname,
                                      int fontnumber,
                                      short platformId,
                                      short encodingId)
Returns the glyph bounding box for the char by using the platform and encoding. If no char is found, null be returned.

Parameters:
glypname - The glyph name.
fontnumber - The font number.
platformId - The platform id.
encodingId - The encoding id.
Returns:
Returns the glyph bounding box for the char.

mapCharCodeToGlyphname

public java.lang.String mapCharCodeToGlyphname(int charCode,
                                               int fontnumber,
                                               short platformId,
                                               short encodingId)
Returns the glyph name for the char by using the platform and encoding. If no char is found, null will be returned.

Parameters:
charCode - The char code.
fontnumber - The font number.
platformId - The platform id.
encodingId - The encoding id.
Returns:
Returns the glyph name for the char.

mapCharCodetoKerning

public int mapCharCodetoKerning(int charcodeLeft,
                                int charcodeRigth,
                                int fontnumber,
                                short platformId,
                                short encodingId)
Returns the kerning for the two chars.

Parameters:
charcodeLeft - The left char code.
charcodeRigth - The right char code.
fontnumber - The font number.
platformId - The platform id.
encodingId - The encoding id.
Returns:
Returns the kerning for the two chars or 0, if no char is found.

mapCharCodetoLigature

public int mapCharCodetoLigature(int charcodeLeft,
                                 int charcodeRigth,
                                 java.util.List<java.lang.String> feature,
                                 java.lang.String language,
                                 int fontnumber,
                                 short platformId,
                                 short encodingId)
Returns the ligature for the two chars.

Parameters:
charcodeLeft - The left char code.
charcodeRigth - The right char code.
feature - The feature tag.
language - The language (null for default).
fontnumber - The font number.
platformId - The platform id.
encodingId - The encoding id.
Returns:
Returns the ligature for the two chars.

mapCharCodeToWidth

public int mapCharCodeToWidth(int charCode,
                              int fontnumber,
                              short platformId,
                              short encodingId)
Returns the glyph width for the char by using the platform and encoding. If no char is found, 0 be returned.

Parameters:
charCode - The char code.
fontnumber - The font number.
platformId - The platform id.
encodingId - The encoding id.
Returns:
Returns the glyph width for the char.

mapCharCodeToWidth

public int mapCharCodeToWidth(java.lang.String glyphname,
                              int fontnumber,
                              short platformId,
                              short encodingId)
Returns the glyph width for the char by using the platform and encoding. If no char is found, 0 be returned.

Parameters:
glyphname - The glyph name.
fontnumber - The font number.
platformId - The platform id.
encodingId - The encoding id.
Returns:
Returns the glyph width for the char.

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)