00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef FONTPOOL_H
00016 #define FONTPOOL_H
00017
00018 #include "pandabase.h"
00019
00020 #include "texture.h"
00021 #include "textFont.h"
00022 #include "filename.h"
00023 #include "lightMutex.h"
00024 #include "pmap.h"
00025
00026
00027
00028
00029
00030
00031
00032
00033 class EXPCL_PANDA_TEXT FontPool {
00034 PUBLISHED:
00035
00036
00037
00038
00039 INLINE static bool has_font(const string &filename);
00040 INLINE static bool verify_font(const string &filename);
00041 BLOCKING INLINE static TextFont *load_font(const string &filename);
00042 INLINE static void add_font(const string &filename, TextFont *font);
00043 INLINE static void release_font(const string &filename);
00044 INLINE static void release_all_fonts();
00045
00046 INLINE static int garbage_collect();
00047
00048 INLINE static void list_contents(ostream &out);
00049 static void write(ostream &out);
00050
00051 private:
00052 INLINE FontPool();
00053
00054 bool ns_has_font(const string &str);
00055 TextFont *ns_load_font(const string &str);
00056 void ns_add_font(const string &str, TextFont *font);
00057 void ns_release_font(const string &str);
00058 void ns_release_all_fonts();
00059 int ns_garbage_collect();
00060 void ns_list_contents(ostream &out) const;
00061
00062 static void lookup_filename(const string &str, string &index_str,
00063 Filename &filename, int &face_index);
00064
00065 static FontPool *get_ptr();
00066 static FontPool *_global_ptr;
00067
00068 LightMutex _lock;
00069 typedef pmap<string, PT(TextFont) > Fonts;
00070 Fonts _fonts;
00071 };
00072
00073 #include "fontPool.I"
00074
00075 #endif