Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _GR_CHAR_WIDTHS_CACHE_H__
00021 #define _GR_CHAR_WIDTHS_CACHE_H__
00022
00023 #include <map>
00024 #include <string>
00025
00026 #include "ut_types.h"
00027
00028 class GR_Font;
00029 class GR_CharWidths;
00030
00031 class ABI_EXPORT GR_CharWidthsCache
00032 {
00033 public:
00034
00038 static GR_CharWidthsCache* getCharWidthCache()
00039 {
00040 _instantiate();
00041 return s_pInstance;
00042 }
00043
00044 enum {
00045 CACHE_FONT_SIZE = 120
00046 };
00047
00048 static void destroyCharWidthsCache()
00049 {
00050 if(s_pInstance)
00051 {
00052 delete s_pInstance;
00053 s_pInstance = NULL;
00054 }
00055 }
00056
00057 protected:
00058 typedef std::map<std::string, GR_CharWidths*> FontCache;
00059
00060 FontCache::iterator addFont (const GR_Font* pFont);
00064 GR_CharWidths* getWidthsForFont(const GR_Font* pFont);
00065 friend class GR_Font;
00066 private:
00067 GR_CharWidthsCache();
00068 ~GR_CharWidthsCache();
00069
00073 static void _instantiate(void);
00074
00078 static GR_CharWidthsCache* s_pInstance;
00082 FontCache m_fontHash;
00083 };
00084
00085
00086 #endif