]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/guiChatConsole.cpp
Implement proper font handling
[dragonfireclient.git] / src / guiChatConsole.cpp
index ec23648f86cad4d155d76eda76ed672fc39c6ba7..c9f41c76fd47fab2eadf31165441f2e343868793 100644 (file)
@@ -27,7 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "main.h"  // for g_settings
 #include "porting.h"
 #include "tile.h"
-#include "IGUIFont.h"
+#include "fontengine.h"
 #include <string>
 
 #include "gettext.h"
@@ -92,19 +92,11 @@ GUIChatConsole::GUIChatConsole(
                m_background_color.setBlue(255);
        }
 
-       // load the font
-       // FIXME should a custom texture_path be searched too?
-       #if USE_FREETYPE
-       std::string font_name = g_settings->get("mono_font_path");
-       u16 font_size = g_settings->getU16("mono_font_size");
-       m_font = gui::CGUITTFont::createTTFont(env, font_name.c_str(), font_size);
-       #else
-       std::string font_name = "fontdejavusansmono.png";
-       m_font = env->getFont(getTexturePath(font_name).c_str());
-       #endif
+       m_font = glb_fontengine->getFont(FONT_SIZE_UNSPECIFIED, FM_Mono);
+
        if (m_font == NULL)
        {
-               dstream << "Unable to load font: " << font_name << std::endl;
+               errorstream << "GUIChatConsole: Unable to load mono font ";
        }
        else
        {
@@ -120,8 +112,7 @@ GUIChatConsole::GUIChatConsole(
 }
 
 GUIChatConsole::~GUIChatConsole()
-{
-}
+{}
 
 void GUIChatConsole::openConsole(f32 height)
 {
@@ -131,6 +122,11 @@ void GUIChatConsole::openConsole(f32 height)
        reformatConsole();
 }
 
+bool GUIChatConsole::isOpen() const
+{
+       return m_open;
+}
+
 bool GUIChatConsole::isOpenInhibited() const
 {
        return m_open_inhibited > 0;
@@ -542,7 +538,13 @@ bool GUIChatConsole::OnEvent(const SEvent& event)
                }
                else if(event.KeyInput.Char != 0 && !event.KeyInput.Control)
                {
-                       m_chat_backend->getPrompt().input(event.KeyInput.Char);
+                       #if (defined(linux) || defined(__linux))
+                               wchar_t wc = L'_';
+                               mbtowc( &wc, (char *) &event.KeyInput.Char, sizeof(event.KeyInput.Char) );
+                               m_chat_backend->getPrompt().input(wc);
+                       #else
+                               m_chat_backend->getPrompt().input(event.KeyInput.Char);
+                       #endif
                        return true;
                }
        }