#include <fontPool.h>
Static Public Member Functions | |
bool | has_font (const string &filename) |
Returns true if the font has ever been loaded, false otherwise. | |
bool | verify_font (const string &filename) |
Loads the given filename up into a font, if it has not already been loaded, and returns true to indicate success, or false to indicate failure. | |
TextFont * | load_font (const string &filename) |
Loads the given filename up into a font, if it has not already been loaded, and returns the new font. | |
void | add_font (const string &filename, TextFont *font) |
Adds the indicated already-loaded font to the pool. | |
void | release_font (const string &filename) |
Removes the indicated font from the pool, indicating it will never be loaded again; the font may then be freed. | |
void | release_all_fonts () |
Releases all fonts in the pool and restores the pool to the empty state. | |
int | garbage_collect () |
Releases only those fonts in the pool that have a reference count of exactly 1; i.e. | |
void | list_contents (ostream &out) |
Lists the contents of the font pool to the indicated output stream. | |
Private Types | |
typedef pmap< string, PT(TextFont) | Fonts ) |
Private Member Functions | |
FontPool () | |
The constructor is not intended to be called directly; there's only supposed to be one FontPool in the universe and it constructs itself. | |
bool | ns_has_font (const string &str) |
The nonstatic implementation of has_font(). | |
TextFont * | ns_load_font (const string &str) |
The nonstatic implementation of load_font(). | |
void | ns_add_font (const string &filename, TextFont *font) |
The nonstatic implementation of add_font(). | |
void | ns_release_font (const string &filename) |
The nonstatic implementation of release_font(). | |
void | ns_release_all_fonts () |
The nonstatic implementation of release_all_fonts(). | |
int | ns_garbage_collect () |
The nonstatic implementation of garbage_collect(). | |
void | ns_list_contents (ostream &out) |
The nonstatic implementation of list_contents(). | |
Static Private Member Functions | |
void | lookup_filename (const string &str, Filename &filename, int &face_index) |
Accepts a font "filename", which might consist of a filename followed by an optional colon and a face index, and splits it out into its two components. | |
FontPool * | get_ptr () |
Initializes and/or returns the global pointer to the one FontPool object in the system. | |
Private Attributes | |
Fonts | _fonts |
Static Private Attributes | |
FontPool * | _global_ptr = (FontPool *)NULL |
It is similar to ModelPool and TexturePool in that it unifies references to the same filename.
Definition at line 46 of file fontPool.h.
|
Definition at line 79 of file fontPool.h. |
|
The constructor is not intended to be called directly; there's only supposed to be one FontPool in the universe and it constructs itself.
Definition at line 184 of file fontPool.I. |
|
Adds the indicated already-loaded font to the pool. The font will always replace any previously-loaded font in the pool that had the same filename. Definition at line 97 of file fontPool.I. References get_ptr(), INLINE, and ns_garbage_collect(). |
|
Releases only those fonts in the pool that have a reference count of exactly 1; i.e. only those fonts that are not being used outside of the pool. Returns the number of fonts released. Definition at line 152 of file fontPool.I. |
|
Initializes and/or returns the global pointer to the one FontPool object in the system.
Definition at line 264 of file fontPool.cxx. Referenced by add_font(), load_font(), and release_font(). |
|
Returns true if the font has ever been loaded, false otherwise.
Definition at line 34 of file fontPool.I. References INLINE, load_font(), and NULL. |
|
Lists the contents of the font pool to the indicated output stream.
Definition at line 167 of file fontPool.I. |
|
Loads the given filename up into a font, if it has not already been loaded, and returns the new font. If a font with the same filename was previously loaded, returns that one instead. If the font file cannot be found, returns NULL. Definition at line 78 of file fontPool.I. References get_ptr(), INLINE, and ns_release_font(). Referenced by has_font(). |
|
Accepts a font "filename", which might consist of a filename followed by an optional colon and a face index, and splits it out into its two components. Then it looks up the filename on the model path. Sets the filename and face index accordingly. Definition at line 226 of file fontPool.cxx. References _global_ptr, and NULL. |
|
The nonstatic implementation of add_font().
Definition at line 124 of file fontPool.cxx. References _fonts. |
|
The nonstatic implementation of garbage_collect().
Definition at line 168 of file fontPool.cxx. References _fonts, and ReferenceCount::get_ref_count(). Referenced by add_font(). |
|
The nonstatic implementation of has_font().
Definition at line 42 of file fontPool.cxx. |
|
The nonstatic implementation of list_contents().
Definition at line 199 of file fontPool.cxx. Referenced by release_font(). |
|
The nonstatic implementation of load_font().
Definition at line 66 of file fontPool.cxx. |
|
The nonstatic implementation of release_all_fonts().
Definition at line 155 of file fontPool.cxx. |
|
The nonstatic implementation of release_font().
Definition at line 138 of file fontPool.cxx. References _fonts. Referenced by load_font(). |
|
Releases all fonts in the pool and restores the pool to the empty state.
Definition at line 133 of file fontPool.I. |
|
Removes the indicated font from the pool, indicating it will never be loaded again; the font may then be freed. If this function is never called, a reference count will be maintained on every font every loaded, and fonts will never be freed. Definition at line 118 of file fontPool.I. References get_ptr(), and ns_list_contents(). |
|
Loads the given filename up into a font, if it has not already been loaded, and returns true to indicate success, or false to indicate failure. If this returns true, it is guaranteed that a subsequent call to load_font() with the same font name will return a valid Font pointer. Definition at line 57 of file fontPool.I. |
|
Definition at line 80 of file fontPool.h. Referenced by ns_add_font(), ns_garbage_collect(), and ns_release_font(). |
|
Definition at line 29 of file fontPool.cxx. Referenced by lookup_filename(). |