00001 #ifndef Impala_Visualization_FontHandler_h
00002 #define Impala_Visualization_FontHandler_h
00003
00004 #include "OglGui/Window.h"
00005 #include "Basis/ILog.h"
00006
00007 namespace Impala {
00008 namespace Visualization {
00009
00010 class FontHandler
00011 {
00012 public:
00013 FontHandler()
00014 {
00015 Init();
00016 }
00017
00018 int
00019 GetFontBase(OglGui::Window *w)
00020 {
00021 if (!mInit) {
00022 mInit = true;
00023 #ifndef OGL_USING_GLUT
00024 ILOG_DEBUG("FontHandler: requesting font handle from Windows...");
00025
00026 const char *fontName = mFont.c_str();
00027
00028 HFONT font = CreateFontA(
00029 -12, 0, 0, 0, FW_NORMAL, 0, 0, 0,
00030 ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS,
00031 ANTIALIASED_QUALITY, VARIABLE_PITCH | FF_DONTCARE, fontName);
00032
00033 ILOG_DEBUG("FontHandler: creating 3D font using Windows...");
00034
00035 mFontBase =
00036 oglSys.Create3DFont( w->GetOGLWND(), font, 1, 0.6f, &fmLogo[0] );
00037
00038 if (mFontBase == NULL)
00039 ILOG_WARN("FontHandler: could not create 3D font base!");
00040
00041 DeleteObject( font );
00042
00043 #else
00044 ILOG_DEBUG("FontHandler: creating 3D font using GLUT...");
00045 mFontBase =
00046 oglSys.Create3DFont( w->GetOGLWND(), NULL, 1, 0.6f, &fmLogo[0] );
00047 #endif
00048 }
00049 return mFontBase;
00050 }
00051
00052 private:
00053 void
00054 Init()
00055 {
00056 mInit = false;
00057 mFontBase = -1;
00058 mFont = "Arial";
00059 }
00060
00061 bool mInit;
00062
00063 FONTMETRIC fmLogo[96];
00064 int mFontBase;
00065 std::string mFont;
00066
00067 ILOG_VAR_DEC;
00068 };
00069
00070 ILOG_VAR_INIT(FontHandler, Visualization);
00071
00072
00073 }
00074 }
00075
00076 #endif