phelps.awt.font

Class NFontTrueType

public class NFontTrueType extends NFontSimple implements OpenType, Cloneable

TrueType outline fonts (.ttf), both Apple and Adobe/Microsoft varieties. It also parses OS X .dfont wrapper. Does not execute the hinting instructions, which apparently requires a license from Apple. Any bitmap glyphs are not supported; if the font contains only bitmaps, as indicated by the subtype, the user should not try to use the font.

Implementation Notes:

Version: $Revision: 1.32 $ $Date: 2004/01/10 07:50:32 $

Field Summary
protected CMapc2g_
In non-CID, mapping from all the way from encoded character through encoding to glyph.
static StringFORMAT
protected float[]lsb_
Indexed by glyph ID.
static intPID_MACINTOSH
Platform ID for Macintosh.
static intPID_MICROSOFT
Platform ID for Microsoft / Windows.
static intPID_UNICODE
Platform ID for Unicode.
static StringSUBFORMAT_BITMAP
Font does not have any outline glyphs, only bitmaps.
static StringSUBFORMAT_DFONT
static StringSUBFORMAT_TTC
TrueType Collection (.ttc).
protected float[]widths_
Indexed by glyph ID.
Constructor Summary
NFontTrueType(URL source)
Creates font from source, which can be file, JAR resource, or even network
NFontTrueType(byte[] data)
Creates font fron byte[], for use on small fonts and fonts embedded in PDF.
Method Summary
booleancanDisplayEchar(char ech)
NFontTrueTypederiveFont(float pointsize)
NFontTrueTypederiveFont(Encoding encoding, CMap toUnicode)
NFontTrueTypederiveFont(CMap cid2gid, CMap toUnicode)
voiddrawEstring(Graphics2D g, String estr, float x, float y, int mode)
doubleecharWidth(char ech)
CMapgetCmap()
Returns CMap in use.
CMapgetCmap(int platformID, int platformSpecificID)
Returns cmap for platformID and platformSpecificID, or null if that table does not exist.
StringgetCopyright()
StringgetDesigner()
StringgetFamily()
intgetFlags()
NFontTrueTypegetFont(int num)
Returns font names of all fonts in file.
intgetFontCount()
byte[]getFontTable(int sfntTag)
Returns the table as an array of bytes for a specified tag.
byte[]getFontTable(String strSfntTag)
Returns the table as an array of bytes for a specified tag.
byte[]getFontTable(int sfntTag, int offset, int count)
Returns a subset of the table as an array of bytes for a specified tag.
byte[]getFontTable(TrueTypeDirectory td, int offset, int count)
byte[]getFontTable(String strSfntTag, int offset, int count)
Returns a subset of the table as an array of bytes for a specified tag.
intgetFontTableSize(int sfntTag)
Returns the size of the table for a specified tag.
intgetFontTableSize(String strSfntTag)
Returns the size of the table for a specified tag.
StringgetFormat()
StringgetName()
intgetNumGlyphs()
chargetSpaceChar()
StringgetSubformat()
TrueTypeDirectorygetTableDirectory(int sfntTag)
TrueTypeDirectory[]getTables()
Returns an array of the font table directories.
intgetVersion()
Returns the font version (first four bytes of file).
intgetWeight()

Field Detail

c2g_

protected CMap c2g_
In non-CID, mapping from all the way from encoded character through encoding to glyph. In CID, mapping from CID to GID.

FORMAT

public static final String FORMAT

lsb_

protected float[] lsb_
Indexed by glyph ID.

PID_MACINTOSH

public static final int PID_MACINTOSH
Platform ID for Macintosh.

PID_MICROSOFT

public static final int PID_MICROSOFT
Platform ID for Microsoft / Windows.

PID_UNICODE

public static final int PID_UNICODE
Platform ID for Unicode.

SUBFORMAT_BITMAP

public static final String SUBFORMAT_BITMAP
Font does not have any outline glyphs, only bitmaps. (Not supported.)

SUBFORMAT_DFONT

public static final String SUBFORMAT_DFONT

SUBFORMAT_TTC

public static final String SUBFORMAT_TTC
TrueType Collection (.ttc). (Not supported.)

widths_

protected float[] widths_
Indexed by glyph ID.

Constructor Detail

NFontTrueType

public NFontTrueType(URL source)
Creates font from source, which can be file, JAR resource, or even network.

NFontTrueType

public NFontTrueType(byte[] data)
Creates font fron byte[], for use on small fonts and fonts embedded in PDF. The memory for data is not reclaimed until the entire font is garbage collected.

Method Detail

canDisplayEchar

public boolean canDisplayEchar(char ech)

deriveFont

public NFontTrueType deriveFont(float pointsize)

deriveFont

public NFontTrueType deriveFont(Encoding encoding, CMap toUnicode)

deriveFont

public NFontTrueType deriveFont(CMap cid2gid, CMap toUnicode)

drawEstring

public void drawEstring(Graphics2D g, String estr, float x, float y, int mode)

echarWidth

public double echarWidth(char ech)

getCmap

public CMap getCmap()
Returns CMap in use.

getCmap

public CMap getCmap(int platformID, int platformSpecificID)
Returns cmap for platformID and platformSpecificID, or null if that table does not exist. Pass -1 to match any value.

getCopyright

public String getCopyright()

getDesigner

public String getDesigner()

getFamily

public String getFamily()

getFlags

public int getFlags()

getFont

public NFontTrueType getFont(int num)
Returns font names of all fonts in file. OS X .dfonts can have multiple fonts bundled in the same file. The different bundled fonts can be obtained by....name? number? By default the first font is used.

getFontCount

public int getFontCount()

getFontTable

public byte[] getFontTable(int sfntTag)
Returns the table as an array of bytes for a specified tag.

getFontTable

public byte[] getFontTable(String strSfntTag)
Returns the table as an array of bytes for a specified tag.

getFontTable

public byte[] getFontTable(int sfntTag, int offset, int count)
Returns a subset of the table as an array of bytes for a specified tag.

getFontTable

public byte[] getFontTable(TrueTypeDirectory td, int offset, int count)

getFontTable

public byte[] getFontTable(String strSfntTag, int offset, int count)
Returns a subset of the table as an array of bytes for a specified tag.

getFontTableSize

public int getFontTableSize(int sfntTag)
Returns the size of the table for a specified tag.

getFontTableSize

public int getFontTableSize(String strSfntTag)
Returns the size of the table for a specified tag.

getFormat

public String getFormat()

getName

public String getName()

getNumGlyphs

public int getNumGlyphs()

getSpaceChar

public char getSpaceChar()

getSubformat

public String getSubformat()

getTableDirectory

public TrueTypeDirectory getTableDirectory(int sfntTag)

getTables

public TrueTypeDirectory[] getTables()
Returns an array of the font table directories.

getVersion

public int getVersion()
Returns the font version (first four bytes of file).

getWeight

public int getWeight()