APIdia Launch Partner
Top Description Fields Constructors Methods
sun.font

public final Class FontResolver

extends Object
Class Inheritance
Imports
java.awt.Font, .GraphicsEnvironment, java.awt.font.TextAttribute, java.text.AttributedCharacterIterator, java.util.ArrayList, .Map

This class maps an individual character to a Font family which can display it. The character-to-Font mapping does not depend on the character's context, so a particular character will be mapped to the same font family each time.

Typically, clients will call getIndexFor(char) for each character in a style run. When getIndexFor() returns a different value from ones seen previously, the characters up to that point will be assigned a font obtained from getFont().

Field Summary

Modifier and TypeField and Description
private Font[]
private int[][]
private static final int
private static final int
private Font
private static FontResolver
private static final int
private static final int
private Font[]
private int[]

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private Font[]
private Font[]
public Font
getFont(int
an index from getFontIndex() which determines the font family
index
,
Map<? extends AttributedCharacterIterator.Attribute, ?>
a Map from which the size and style of the Font are determined. The default size is 12 and the default style is Font.PLAIN
attributes
)

Return a Font from a given font index with properties from attributes.

public int

Returns:

a value for consumption by getFont()
getFontIndex
(char
the character to map
c
)

Return an index for the given character.

public int
getFontIndex(int cp)

private int
getIndexFor(char c)

Search fonts in order, and return "1" to indicate its in the default font, (or not found at all), or the index of the first font which can display the given character, plus 2, if it is not in the default font.

private int
getIndexFor(int cp)

public static FontResolver
getInstance()

Return a shared instance of FontResolver.

public int

Returns:

the font index for the initial code point found, or 1 if the iterator was empty.
nextFontRunIndex
(CodePointIterator
a code point iterator, this will be advanced past any code points that have the same font index
iter
)

Determines the font index for the code point at the current position in the iterator, then advances the iterator to the first code point that has a different index or until the iterator is DONE, and returns the font index.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

allFontsback to summary
private Font[] allFonts
blocksback to summary
private int[][] blocks
BLOCKSIZEback to summary
private static final int BLOCKSIZE
DEFAULT_SIZEback to summary
private static final int DEFAULT_SIZE
defaultFontback to summary
private Font defaultFont
INSTANCEback to summary
private static FontResolver INSTANCE
MASKback to summary
private static final int MASK
SHIFTback to summary
private static final int SHIFT
supplementaryFontsback to summary
private Font[] supplementaryFonts
supplementaryIndicesback to summary
private int[] supplementaryIndices

Constructor Detail

FontResolverback to summary
private FontResolver()

Method Detail

getAllFontsback to summary
private Font[] getAllFonts()
getAllSCFontsback to summary
private Font[] getAllSCFonts()
getFontback to summary
public Font getFont(int index, Map<? extends AttributedCharacterIterator.Attribute, ?> attributes)

Return a Font from a given font index with properties from attributes. The font index, which should have been produced by getFontIndex(), determines a font family. The size and style of the Font reflect the properties in attributes. Any Font or font family specifications in attributes are ignored, on the assumption that clients have already handled them.

Parameters
index:int

an index from getFontIndex() which determines the font family

attributes:Map<? extends AttributedCharacterIterator.Attribute, ?>

a Map from which the size and style of the Font are determined. The default size is 12 and the default style is Font.PLAIN

See Also
getFontIndex
getFontIndexback to summary
public int getFontIndex(char c)

Return an index for the given character. The index identifies a font family to getFont(), and has no other inherent meaning.

Parameters
c:char

the character to map

Returns:int

a value for consumption by getFont()

See Also
getFont
getFontIndexback to summary
public int getFontIndex(int cp)
getIndexForback to summary
private int getIndexFor(char c)

Search fonts in order, and return "1" to indicate its in the default font, (or not found at all), or the index of the first font which can display the given character, plus 2, if it is not in the default font.

getIndexForback to summary
private int getIndexFor(int cp)
getInstanceback to summary
public static FontResolver getInstance()

Return a shared instance of FontResolver.

nextFontRunIndexback to summary
public int nextFontRunIndex(CodePointIterator iter)

Determines the font index for the code point at the current position in the iterator, then advances the iterator to the first code point that has a different index or until the iterator is DONE, and returns the font index.

Parameters
iter:CodePointIterator

a code point iterator, this will be advanced past any code points that have the same font index

Returns:int

the font index for the initial code point found, or 1 if the iterator was empty.