public final class

FontResolver

extends Object
java.lang.Object
   ↳ sun.font.FontResolver

Class Overview

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().

Summary

Public Methods
Font getFont(int index, Map attributes)
Return a Font from a given font index with properties from attributes.
int getFontIndex(int cp)
int getFontIndex(char c)
Return an index for the given character.
static FontResolver getInstance()
Return a shared instance of FontResolver.
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.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public Font getFont (int index, Map 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 an index from getFontIndex() which determines the font family
attributes 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

public int getFontIndex (int cp)

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 the character to map
Returns
  • a value for consumption by getFont()

public static FontResolver getInstance ()

Return a shared instance of FontResolver.

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 a code point iterator, this will be advanced past any code points that have the same font index
Returns
  • the font index for the initial code point found, or 1 if the iterator was empty.