Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/text/fontPool.h

Go to the documentation of this file.
00001 // Filename: fontPool.h
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 #ifndef FONTPOOL_H
00020 #define FONTPOOL_H
00021 
00022 #include "pandabase.h"
00023 
00024 #include "texture.h"
00025 #include "textFont.h"
00026 
00027 #include "filename.h"
00028 #include "pmap.h"
00029 
00030 ////////////////////////////////////////////////////////////////////
00031 //       Class : FontPool
00032 // Description : This is the preferred interface for loading fonts for
00033 //               the TextNode system.  It is similar to ModelPool and
00034 //               TexturePool in that it unifies references to the same
00035 //               filename.
00036 ////////////////////////////////////////////////////////////////////
00037 class EXPCL_PANDA FontPool {
00038 PUBLISHED:
00039   // These functions take string parameters instead of Filenames
00040   // because that's somewhat more convenient to the scripting
00041   // language.
00042   INLINE static bool has_font(const string &filename);
00043   INLINE static bool verify_font(const string &filename);
00044   INLINE static TextFont *load_font(const string &filename);
00045   INLINE static void add_font(const string &filename, TextFont *font);
00046   INLINE static void release_font(const string &filename);
00047   INLINE static void release_all_fonts();
00048 
00049   INLINE static int garbage_collect();
00050 
00051   INLINE static void list_contents(ostream &out);
00052 
00053 private:
00054   INLINE FontPool();
00055 
00056   bool ns_has_font(const string &str);
00057   TextFont *ns_load_font(const string &str);
00058   void ns_add_font(const string &filename, TextFont *font);
00059   void ns_release_font(const string &filename);
00060   void ns_release_all_fonts();
00061   int ns_garbage_collect();
00062   void ns_list_contents(ostream &out);
00063 
00064   static void lookup_filename(const string &str,
00065                               Filename &filename, int &face_index);
00066 
00067   static FontPool *get_ptr();
00068 
00069   static FontPool *_global_ptr;
00070   typedef pmap<string,  PT(TextFont) > Fonts;
00071   Fonts _fonts;
00072 };
00073 
00074 #include "fontPool.I"
00075 
00076 #endif

Generated on Fri May 2 00:44:16 2003 for Panda by doxygen1.3