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