APIdia Launch Partner
Top Description Inners Fields Constructors Methods
sun.font

public Class TrueTypeFont

extends FileFont
Class Inheritance
Imports
java.awt.Font, .FontFormatException, java.awt.geom.Point2D, java.io.FileNotFoundException, .IOException, .RandomAccessFile, .UnsupportedEncodingException, java.nio.ByteBuffer, .CharBuffer, .IntBuffer, .ShortBuffer, java.nio.channels.ClosedChannelException, .FileChannel, java.util.HashMap, .HashSet, .Locale, .Map, sun.java2d.Disposer, .DisposerRecord

TrueTypeFont is not called SFntFont because it is not expected to handle all types that may be housed in a such a font file. If additional types are supported later, it may make sense to create an SFnt superclass. Eg to handle sfnt-housed postscript fonts. OpenType fonts are handled by this class, and possibly should be represented by a subclass. An instance stores some information from the font file to facilitate faster access. File size, the table directory and the names of the font are the most important of these. It amounts to approx 400 bytes for a typical font. Systems with multiple locales sometimes have up to 400 font files, and an app which loads all font files would need around 160Kbytes. So storing any more info than this would be expensive.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
private static class

Field Summary

Modifier and TypeField and Description
public static final int
private static final String[]
private static String
pack-priv int
private static final int
private static final int
pack-priv int
pack-priv TrueTypeFont.TTDisposerRecord
public static final int
private static final short[]
pack-priv static final String[]
public static final short
public static final int
public static final int
public static final int
pack-priv int
pack-priv int
private int
private int
private static final int
private static final int
private static final int
public static final int
public static final int
private char[]
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
private short[]
private static final String[][]
private static Map<String, short[]>
private static Map<String, Short>
private String
private String
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
private Locale
public static final int
pack-priv int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
private float
private float
private boolean
private boolean
pack-priv TrueTypeFont.DirectoryEntry[]
public static final int
public static final int
private static final int
private float
private float
private static final short
public static final int
Inherited from sun.font.FileFont:
fileSizeglyphToCharMapnativeFontsscaleruseJavaRasterizer

Constructor Summary

AccessConstructor and Description
public
TrueTypeFont(String platname, Object nativeNames, int fIndex, boolean javaRasterizer)

public
TrueTypeFont(String platname, Object nativeNames, int fIndex, boolean javaRasterizer, boolean useFilePool)

- does basic verification of the file - reads the header table for this font (within a collection) - reads the names (full, family).

Method Summary

Modifier and TypeMethod and Description
private static void
addLCIDMapEntry(Map<String, Short> map, String key, short value)

protected synchronized void
close()

Implements abstract sun.font.FileFont.close.

private static void
private static synchronized void
pack-priv String[]
pack-priv String[]
pack-priv static String
pack-priv TrueTypeFont.DirectoryEntry
public String
public int
getFontCount()

Returns: number of logical fonts.

public String
public String
private char[]
pack-priv Point2D.Float
getGlyphPoint(long pScalerContext, int glyphCode, int ptNumber)

Overrides sun.font.PhysicalFont.getGlyphPoint.

private static short[]
private static short
public CharToGlyphMapper
getMapper()

Implements abstract sun.font.Font2D.getMapper.

public String
protected synchronized FontScaler
getScaler()

Implements abstract sun.font.FileFont.getScaler.

public void
getStyleMetrics(float pointSize, float[] metrics, int offset)

Overrides sun.font.Font2D.getStyleMetrics.

The length of the metrics array must be >= offset+4, and offset must be >= 0.

pack-priv ByteBuffer
getTableBuffer(int tag)

protected byte[]
pack-priv int
getTableOffset(int tag)

pack-priv int
getTableSize(int tag)

public int
public int
public boolean
protected void
init(int fIndex)

protected void
initAllNames(int requestedID, HashSet<String> names)

protected void
private boolean
protected String
lookupName(short findLocaleID, int findNameID)

private String
makeString(byte[] bytes, int len, short platformID, short encoding)

private synchronized FileChannel
open()

private synchronized FileChannel
open(boolean usePool)

pack-priv int
readBlock(ByteBuffer buffer, int offset, int length)

pack-priv ByteBuffer
readBlock(int offset, int length)

Implements abstract sun.font.FileFont.readBlock.

pack-priv byte[]
readBytes(int offset, int length)

private void
private void
setStrikethroughMetrics(ByteBuffer os_2Table, int upem)

protected void
private void
setStyle(ByteBuffer os_2Table)

private void
setUnderlineMetrics(ByteBuffer postTable, int upem)

pack-priv boolean
pack-priv boolean
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public boolean
pack-priv boolean
private void
verify(boolean usePool)

Inherited from sun.font.FileFont:
canDoStylecreateStrikederegisterFontAndClearStrikeCachegetFontMetricsgetGlyphAdvancegetGlyphImagegetGlyphMetricsgetGlyphOutlinegetGlyphOutlineBoundsgetGlyphVectorOutlinegetPublicFileNamegetUnitsPerEmsetFileToRemove

Field Detail

cmapTagback to summary
public static final int cmapTag
codePagesback to summary
private static final String[] codePages
defaultCodePageback to summary
private static String defaultCodePage
directoryCountback to summary
pack-priv int directoryCount
DIRECTORYENTRYSIZEback to summary
private static final int DIRECTORYENTRYSIZE
DIRECTORYHEADERSIZEback to summary
private static final int DIRECTORYHEADERSIZE
directoryOffsetback to summary
pack-priv int directoryOffset
disposerRecordback to summary
pack-priv TrueTypeFont.TTDisposerRecord disposerRecord
EBLCTagback to summary
public static final int EBLCTag
EMPTY_COMPATIBLE_LCIDSback to summary
private static final short[] EMPTY_COMPATIBLE_LCIDS
encoding_mappingback to summary
pack-priv static final String[] encoding_mapping
ENGLISH_LOCALE_IDback to summary
public static final short ENGLISH_LOCALE_ID
FAMILY_NAME_IDback to summary
public static final int FAMILY_NAME_ID
fdscTagback to summary
public static final int fdscTag
featTagback to summary
public static final int featTag
fontDataSizeback to summary
pack-priv int fontDataSize
fontIndexback to summary
pack-priv int fontIndex
fontWeightback to summary
private int fontWeight
fontWidthback to summary
private int fontWidth
fsSelectionBoldBitback to summary
private static final int fsSelectionBoldBit
fsSelectionItalicBitback to summary
private static final int fsSelectionItalicBit
fsSelectionRegularBitback to summary
private static final int fsSelectionRegularBit
FULL_NAME_IDback to summary
public static final int FULL_NAME_ID
fvarTagback to summary
public static final int fvarTag
gaspTableback to summary
private char[] gaspTable
gaspTagback to summary
public static final int gaspTag
GDEFTagback to summary
public static final int GDEFTag
glyfTagback to summary
public static final int glyfTag
GPOSTagback to summary
public static final int GPOSTag
GSUBTagback to summary
public static final int GSUBTag
headTagback to summary
public static final int headTag
hheaTagback to summary
public static final int hheaTag
hmtxTagback to summary
public static final int hmtxTag
languageCompatibleLCIDsback to summary
private short[] languageCompatibleLCIDs
languagesback to summary
private static final String[][] languages
lcidLanguageCompatibilityMapback to summary
private static Map<String, short[]> lcidLanguageCompatibilityMap
lcidMapback to summary
private static Map<String, Short> lcidMap
localeFamilyNameback to summary
private String localeFamilyName
localeFullNameback to summary
private String localeFullName
locaTagback to summary
public static final int locaTag
MAC_PLATFORM_IDback to summary
public static final int MAC_PLATFORM_ID
MACROMAN_ENGLISH_LANGback to summary
public static final int MACROMAN_ENGLISH_LANG
MACROMAN_SPECIFIC_IDback to summary
public static final int MACROMAN_SPECIFIC_ID
maxpTagback to summary
public static final int maxpTag
mortTagback to summary
public static final int mortTag
morxTagback to summary
public static final int morxTag
MS_PLATFORM_IDback to summary
public static final int MS_PLATFORM_ID
nameLocaleback to summary
private Locale nameLocale
nameTagback to summary
public static final int nameTag
numTablesback to summary
pack-priv int numTables
os_2Tagback to summary
public static final int os_2Tag
ottoTagback to summary
public static final int ottoTag
POSTSCRIPT_NAME_IDback to summary
public static final int POSTSCRIPT_NAME_ID
postTagback to summary
public static final int postTag
reserved_bits1back to summary
public static final int reserved_bits1
reserved_bits2back to summary
public static final int reserved_bits2
stPosback to summary
private float stPos
stSizeback to summary
private float stSize
supportsCJKback to summary
private boolean supportsCJK
supportsJAback to summary
private boolean supportsJA
tableDirectoryback to summary
pack-priv TrueTypeFont.DirectoryEntry[] tableDirectory
trueTagback to summary
public static final int trueTag
ttcfTagback to summary
public static final int ttcfTag
TTCHEADERSIZEback to summary
private static final int TTCHEADERSIZE
ulPosback to summary
private float ulPos
ulSizeback to summary
private float ulSize
US_LCIDback to summary
private static final short US_LCID
v1ttTagback to summary
public static final int v1ttTag

Constructor Detail

TrueTypeFontback to summary
public TrueTypeFont(String platname, Object nativeNames, int fIndex, boolean javaRasterizer) throws FontFormatException
TrueTypeFontback to summary
public TrueTypeFont(String platname, Object nativeNames, int fIndex, boolean javaRasterizer, boolean useFilePool) throws FontFormatException

- does basic verification of the file - reads the header table for this font (within a collection) - reads the names (full, family). - determines the style of the font. - initializes the CMAP

Exceptions
FontFormatException:
if the font can't be opened or fails verification, or there's no usable cmap

Method Detail

addLCIDMapEntryback to summary
private static void addLCIDMapEntry(Map<String, Short> map, String key, short value)
closeback to summary
protected synchronized void close()

Implements abstract sun.font.FileFont.close.

createLCIDLanguageCompatibilityMapback to summary
private static void createLCIDLanguageCompatibilityMap()
createLCIDMapback to summary
private static synchronized void createLCIDMap()
getAllFamilyNamesback to summary
pack-priv String[] getAllFamilyNames()
getAllFullNamesback to summary
pack-priv String[] getAllFullNames()
getCodePageback to summary
pack-priv static String getCodePage()
getDirectoryEntryback to summary
pack-priv TrueTypeFont.DirectoryEntry getDirectoryEntry(int tag)
getFamilyNameback to summary
public String getFamilyName(Locale locale)

Overrides sun.font.Font2D.getFamilyName.

Annotations
@Override
getFontCountback to summary
public int getFontCount()
Returns:int

number of logical fonts. Is "1" for all but TTC files

getFontNameback to summary
public String getFontName(Locale locale)

Overrides sun.font.Font2D.getFontName.

Annotations
@Override
getFullNameback to summary
public String getFullName()
getGaspTableback to summary
private char[] getGaspTable()
getGlyphPointback to summary
pack-priv Point2D.Float getGlyphPoint(long pScalerContext, int glyphCode, int ptNumber)

Overrides sun.font.PhysicalFont.getGlyphPoint.

Annotations
@Override
getLanguageCompatibleLCIDsFromLocaleback to summary
private static short[] getLanguageCompatibleLCIDsFromLocale(Locale locale)
getLCIDFromLocaleback to summary
private static short getLCIDFromLocale(Locale locale)
getMapperback to summary
public CharToGlyphMapper getMapper()

Implements abstract sun.font.Font2D.getMapper.

getPostscriptNameback to summary
public String getPostscriptName()

Overrides sun.font.Font2D.getPostscriptName.

Annotations
@Override
getScalerback to summary
protected synchronized FontScaler getScaler()

Implements abstract sun.font.FileFont.getScaler.

getStyleMetricsback to summary
public void getStyleMetrics(float pointSize, float[] metrics, int offset)

Overrides sun.font.Font2D.getStyleMetrics.

Doc from sun.font.Font2D.getStyleMetrics.

The length of the metrics array must be >= offset+4, and offset must be >= 0. Typically offset is 4. This method will store the following elements in that array before returning: metrics[off+0]: strikethrough offset metrics[off+1]: strikethrough thickness metrics[off+2]: underline offset metrics[off+3]: underline thickness Note that this implementation simply returns default values; subclasses can override this method to provide more accurate values.

Annotations
@Override
getTableBufferback to summary
pack-priv ByteBuffer getTableBuffer(int tag)
getTableBytesback to summary
protected byte[] getTableBytes(int tag)

Overrides sun.font.Font2D.getTableBytes.

Annotations
@Override
getTableOffsetback to summary
pack-priv int getTableOffset(int tag)
getTableSizeback to summary
pack-priv int getTableSize(int tag)
getWeightback to summary
public int getWeight()

Overrides sun.font.Font2D.getWeight.

Annotations
@Override
getWidthback to summary
public int getWidth()

Overrides sun.font.Font2D.getWidth.

Annotations
@Override
hasSupplementaryCharsback to summary
public boolean hasSupplementaryChars()

Overrides sun.font.Font2D.hasSupplementaryChars.

Annotations
@Override
initback to summary
protected void init(int fIndex) throws FontFormatException
initAllNamesback to summary
protected void initAllNames(int requestedID, HashSet<String> names)
initNamesback to summary
protected void initNames()
isLanguageCompatibleback to summary
private boolean isLanguageCompatible(short lcid)
lookupNameback to summary
protected String lookupName(short findLocaleID, int findNameID)
makeStringback to summary
private String makeString(byte[] bytes, int len, short platformID, short encoding)
openback to summary
private synchronized FileChannel open() throws FontFormatException
openback to summary
private synchronized FileChannel open(boolean usePool) throws FontFormatException
readBlockback to summary
pack-priv int readBlock(ByteBuffer buffer, int offset, int length)
readBlockback to summary
pack-priv ByteBuffer readBlock(int offset, int length)

Implements abstract sun.font.FileFont.readBlock.

readBytesback to summary
pack-priv byte[] readBytes(int offset, int length)
setCJKSupportback to summary
private void setCJKSupport(ByteBuffer os2Table)
setStrikethroughMetricsback to summary
private void setStrikethroughMetrics(ByteBuffer os_2Table, int upem)
setStyleback to summary
protected void setStyle()

Overrides sun.font.Font2D.setStyle.

Annotations
@Override
setStyleback to summary
private void setStyle(ByteBuffer os_2Table)
setUnderlineMetricsback to summary
private void setUnderlineMetrics(ByteBuffer postTable, int upem)
supportsEncodingback to summary
pack-priv boolean supportsEncoding(String encoding)

Overrides sun.font.Font2D.supportsEncoding.

Annotations
@Override
supportsJAback to summary
pack-priv boolean supportsJA()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override
useAAForPtSizeback to summary
public boolean useAAForPtSize(int ptsize)

Overrides sun.font.Font2D.useAAForPtSize.

Annotations
@Override
useEmbeddedBitmapsForSizeback to summary
pack-priv boolean useEmbeddedBitmapsForSize(int ptSize)
verifyback to summary
private void verify(boolean usePool) throws FontFormatException
sun.font back to summary

pack-priv Class TrueTypeFont.DirectoryEntry

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv int
pack-priv int
pack-priv int

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

lengthback to summary
pack-priv int length
offsetback to summary
pack-priv int offset
tagback to summary
pack-priv int tag

Constructor Detail

DirectoryEntryback to summary
pack-priv DirectoryEntry()
sun.font back to summary

private Class TrueTypeFont.TTDisposerRecord

extends Object
implements DisposerRecord
Class Inheritance
All Implemented Interfaces
sun.java2d.DisposerRecord

Field Summary

Modifier and TypeField and Description
pack-priv FileChannel

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public synchronized void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

channelback to summary
pack-priv FileChannel channel

Constructor Detail

TTDisposerRecordback to summary
private TTDisposerRecord()

Method Detail

disposeback to summary
public synchronized void dispose()

Implements sun.java2d.DisposerRecord.dispose.