Class FontCache

  extended by<T>
      extended by<T>
          extended by<Font>
              extended by
All Implemented Interfaces:
java.lang.Iterable<Font>, Destroyable, Factory<Font>, Accepter<Font>, Container<Font>, KeyedContainer<Font>, Remover<Font>

public class FontCache
extends GroupedCache<Font>

Rather obviously, a FontCache is a GroupedCache that contains Fonts. FontCache has one additional bit of functionality, however. It has a "default" font that it maintains a direct reference to. Whenever a font is requested that is not in the Cache, it automatically returns the default. Though a default font is automatically in place, any font in the Cache can be set as the default. Initially, the Cache is full and the default font is null. It's highly recommended to set the default font on startup. NOTE: It's really not recommended to use the "dynamic creation" capabilities of a Cache when dealing with Fonts. There are reasons: 1: Fonts are heavy-duty, and they take a long time to load. It's much better to the user if font loading takes place out-of-game. 2: The default FontRenderers work best if more than one String is used to instantiate them. For example, an AngelCodeRenderer requires both a path to a font file and a path to an image.

Chris Molini

Nested Class Summary
Nested classes/interfaces inherited from class
Field Summary
private  Font defaultFont
          The reference to the default font.
Fields inherited from class
Fields inherited from class
contents, factory
Constructor Summary
          Creates a default, empty FontCache.
Method Summary
 Font defaultFont()
          Obtains the current default font.
 java.lang.String defaultFontName()
          Gets information about the default font.
 boolean setDefaultFont(java.lang.String font)
          Sets the default font.
Methods inherited from class
addGroup, addGroup, addIntoGroup, addIntoGroup, addIntoGroup, addIntoGroup, clearGroups, destroyGroup, disgroup, emptyGroup, groups, objectsReferenced, objectsReferenced, removeFromGroup, wipeGroup
Methods inherited from class
destroy, get, get, removeAndDestroy, setTo
Methods inherited from class
add, add, add, add, clear, contains, contains, create, createMap, factory, iterator, remove, remove, remove, remove, setFactory, size
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail


private Font defaultFont
The reference to the default font.

Constructor Detail


public FontCache()
Creates a default, empty FontCache. The default font reference is null.

Method Detail


public java.lang.String defaultFontName()
Gets information about the default font.

The default font's name.


public Font defaultFont()
Obtains the current default font.

A reference to the default font.


public boolean setDefaultFont(java.lang.String font)
Sets the default font.

font - The font identifier to find the desired font.
Whether or not the assignment succeeded. This call fails if the indicated font is not in the Cache.