00001 // Filename: fontPool.I 00002 // Created by: drose (31Jan03) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00008 // 00009 // All use of this software is subject to the terms of the Panda 3d 00010 // Software license. You should have received a copy of this license 00011 // along with this source code; you will also find a current copy of 00012 // the license at http://www.panda3d.org/license.txt . 00013 // 00014 // To contact the maintainers of this program write to 00015 // panda3d@yahoogroups.com . 00016 // 00017 //////////////////////////////////////////////////////////////////// 00018 00019 00020 //////////////////////////////////////////////////////////////////// 00021 // Function: FontPool::has_font 00022 // Access: Public, Static 00023 // Description: Returns true if the font has ever been loaded, 00024 // false otherwise. 00025 //////////////////////////////////////////////////////////////////// 00026 INLINE bool FontPool:: 00027 has_font(const string &filename) { 00028 return get_ptr()->ns_has_font(filename); 00029 } 00030 00031 //////////////////////////////////////////////////////////////////// 00032 // Function: FontPool::verify_font 00033 // Access: Public, Static 00034 // Description: Loads the given filename up into a font, if it has 00035 // not already been loaded, and returns true to indicate 00036 // success, or false to indicate failure. If this 00037 // returns true, it is guaranteed that a subsequent call 00038 // to load_font() with the same font name will 00039 // return a valid Font pointer. 00040 //////////////////////////////////////////////////////////////////// 00041 INLINE bool FontPool:: 00042 verify_font(const string &filename) { 00043 return load_font(filename) != (TextFont *)NULL; 00044 } 00045 00046 //////////////////////////////////////////////////////////////////// 00047 // Function: FontPool::load_font 00048 // Access: Public, Static 00049 // Description: Loads the given filename up into a font, if it has 00050 // not already been loaded, and returns the new font. 00051 // If a font with the same filename was previously 00052 // loaded, returns that one instead. If the font 00053 // file cannot be found, returns NULL. 00054 //////////////////////////////////////////////////////////////////// 00055 INLINE TextFont *FontPool:: 00056 load_font(const string &filename) { 00057 return get_ptr()->ns_load_font(filename); 00058 } 00059 00060 //////////////////////////////////////////////////////////////////// 00061 // Function: FontPool::add_font 00062 // Access: Public, Static 00063 // Description: Adds the indicated already-loaded font to the 00064 // pool. The font will always replace any 00065 // previously-loaded font in the pool that had the 00066 // same filename. 00067 //////////////////////////////////////////////////////////////////// 00068 INLINE void FontPool:: 00069 add_font(const string &filename, TextFont *font) { 00070 get_ptr()->ns_add_font(filename, font); 00071 } 00072 00073 //////////////////////////////////////////////////////////////////// 00074 // Function: FontPool::release_font 00075 // Access: Public, Static 00076 // Description: Removes the indicated font from the pool, 00077 // indicating it will never be loaded again; the font 00078 // may then be freed. If this function is never called, 00079 // a reference count will be maintained on every font 00080 // every loaded, and fonts will never be freed. 00081 //////////////////////////////////////////////////////////////////// 00082 INLINE void FontPool:: 00083 release_font(const string &filename) { 00084 get_ptr()->ns_release_font(filename); 00085 } 00086 00087 //////////////////////////////////////////////////////////////////// 00088 // Function: FontPool::release_all_fonts 00089 // Access: Public, Static 00090 // Description: Releases all fonts in the pool and restores the 00091 // pool to the empty state. 00092 //////////////////////////////////////////////////////////////////// 00093 INLINE void FontPool:: 00094 release_all_fonts() { 00095 get_ptr()->ns_release_all_fonts(); 00096 } 00097 00098 //////////////////////////////////////////////////////////////////// 00099 // Function: FontPool::garbage_collect 00100 // Access: Public, Static 00101 // Description: Releases only those fonts in the pool that have a 00102 // reference count of exactly 1; i.e. only those 00103 // fonts that are not being used outside of the pool. 00104 // Returns the number of fonts released. 00105 //////////////////////////////////////////////////////////////////// 00106 INLINE int FontPool:: 00107 garbage_collect() { 00108 return get_ptr()->ns_garbage_collect(); 00109 } 00110 00111 //////////////////////////////////////////////////////////////////// 00112 // Function: FontPool::list_contents 00113 // Access: Public, Static 00114 // Description: Lists the contents of the font pool to the 00115 // indicated output stream. 00116 //////////////////////////////////////////////////////////////////// 00117 INLINE void FontPool:: 00118 list_contents(ostream &out) { 00119 get_ptr()->ns_list_contents(out); 00120 } 00121 00122 //////////////////////////////////////////////////////////////////// 00123 // Function: FontPool::Constructor 00124 // Access: Private 00125 // Description: The constructor is not intended to be called 00126 // directly; there's only supposed to be one FontPool 00127 // in the universe and it constructs itself. 00128 //////////////////////////////////////////////////////////////////// 00129 INLINE FontPool:: 00130 FontPool() { 00131 }