org.foray.font.format.ttf
Class TTFOffsetTable

java.lang.Object
  extended by org.foray.font.format.ttf.TTFOffsetTable

public final class TTFOffsetTable
extends Object

A TrueType or OpenType Offset Table, the very first item in the content of a font. Even though it calls itself a "table" it is not part of the TrueType table hierarchy. It is a table of tables that describes how to find each of the tables in the font. Note that although it is the first item in the content of a font, it may not be the first item in the content of a font file. If the file is a TrueType collection of some sort, the offset to the Offset Table for each font is indicated in the TTCHeader.


Field Summary
static byte OFFSET_TABLE_SIZE
          Constant indicating the size of the table directory itself, in bytes.
static byte SEARCH_RANGE_CONSTANT
          Constant used in the computation of the search range and range shift values.
static int TTF_FILE_SFNT_VERSION_1
          Constant indicating the sfnt version for the table directory.
 
Method Summary
protected  TTFOffsetTableRecord getTableDirectoryEntry(String tableName)
          Return the table directory entry for a given table name.
 TrueTypeContainer getTTFFile()
          Returns the parent TTFFile.
 TrueTypeFont getTTFFont()
          Returns the TTFFont related to this table directory.
static TTFOffsetTable parse(TrueTypeContainer container, RandomAccessInput raInput, long fileOffset)
          Parse a Table Directory from the appropriate offset.
 void parseFont()
          Parses the font described by this table directory and stores the parsed instance in this for retrieval with getTTFFont().
 void setTTFFont(TrueTypeFont newFont)
          Sets the TTFFont for this table directory.
 boolean ttfFontCreated()
          Indicates whether the font has been created.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TTF_FILE_SFNT_VERSION_1

public static final int TTF_FILE_SFNT_VERSION_1
Constant indicating the sfnt version for the table directory.

See Also:
Constant Field Values

SEARCH_RANGE_CONSTANT

public static final byte SEARCH_RANGE_CONSTANT
Constant used in the computation of the search range and range shift values.

See Also:
Constant Field Values

OFFSET_TABLE_SIZE

public static final byte OFFSET_TABLE_SIZE
Constant indicating the size of the table directory itself, in bytes.

See Also:
Constant Field Values
Method Detail

parse

public static TTFOffsetTable parse(TrueTypeContainer container,
                                   RandomAccessInput raInput,
                                   long fileOffset)
                            throws IOException
Parse a Table Directory from the appropriate offset. Create the HashMap entries using the table name as the key and the appropriate TTFDirTabEntry as the value.

Parameters:
container - The font parent container.
raInput - The input being parsed.
fileOffset - The offset to the specific font in container that should be parsed (remember that a TTF font file can contain more than one TTF font.
Returns:
The parsed instance.
Throws:
IOException - For I/O error.

getTableDirectoryEntry

protected TTFOffsetTableRecord getTableDirectoryEntry(String tableName)
Return the table directory entry for a given table name.

Parameters:
tableName - The name of the table whose table directory entry is sought.
Returns:
The table directory entry for tableName.

ttfFontCreated

public boolean ttfFontCreated()
Indicates whether the font has been created.

Returns:
True iff the TrueTypeFont instance has been instantiated.

parseFont

public void parseFont()
               throws IOException
Parses the font described by this table directory and stores the parsed instance in this for retrieval with getTTFFont().

Throws:
IOException - For I/O errors during parsing.

getTTFFont

public TrueTypeFont getTTFFont()
Returns the TTFFont related to this table directory.

Returns:
The TTFFont related to this table directory.

setTTFFont

public void setTTFFont(TrueTypeFont newFont)
Sets the TTFFont for this table directory.

Parameters:
newFont - The TTFFont for this table directory.

getTTFFile

public TrueTypeContainer getTTFFile()
Returns the parent TTFFile.

Returns:
The parent TTFFile.


Copyright © 2017. All rights reserved.