aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorsapier <Sapier at GMX dot net>2014-11-23 13:40:43 +0100
committersapier <Sapier at GMX dot net>2014-11-30 17:50:09 +0100
commitdceb9f7d6058785cf60d9dbcc8eecdcee1053412 (patch)
tree0cbaa6969210d3e104f195ac5d3c2cabad8d6338 /src/main.cpp
parent25945dc5395a03cab069ff0e6470ba8d59b03978 (diff)
downloadminetest-dceb9f7d6058785cf60d9dbcc8eecdcee1053412.tar.gz
minetest-dceb9f7d6058785cf60d9dbcc8eecdcee1053412.tar.bz2
minetest-dceb9f7d6058785cf60d9dbcc8eecdcee1053412.zip
Implement proper font handling
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp51
1 files changed, 7 insertions, 44 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 201995b5c..7141bec66 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -69,9 +69,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "profiler.h"
#include "log.h"
#include "mods.h"
-#if USE_FREETYPE
-#include "xCGUITTFont.h"
-#endif
#include "util/string.h"
#include "subgame.h"
#include "quicktune.h"
@@ -80,6 +77,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "guiEngine.h"
#include "mapsector.h"
#include "player.h"
+#include "fontengine.h"
#include "database-sqlite3.h"
#ifdef USE_LEVELDB
@@ -1571,13 +1569,11 @@ ClientLauncher::~ClientLauncher()
if (input)
delete input;
+ if (glb_fontengine)
+ delete glb_fontengine;
+
if (device)
device->drop();
-
-#if USE_FREETYPE
- if (use_freetype && font != NULL)
- font->drop();
-#endif
}
bool ClientLauncher::run(GameParams &game_params, const Settings &cmd_args)
@@ -1593,8 +1589,6 @@ bool ClientLauncher::run(GameParams &game_params, const Settings &cmd_args)
return false;
}
- late_init_default_settings(g_settings);
-
// Speed tests (done after irrlicht is loaded to get timer)
if (cmd_args.getFlag("speedtests")) {
dstream << "Running speed tests" << std::endl;
@@ -1630,45 +1624,15 @@ bool ClientLauncher::run(GameParams &game_params, const Settings &cmd_args)
guienv = device->getGUIEnvironment();
skin = guienv->getSkin();
- std::string font_path = g_settings->get("font_path");
-
-#if USE_FREETYPE
-
- if (use_freetype) {
- std::string fallback;
- if (is_yes(gettext("needs_fallback_font")))
- fallback = "fallback_";
- u16 font_size = g_settings->getU16(fallback + "font_size");
- font_path = g_settings->get(fallback + "font_path");
- u32 font_shadow = g_settings->getU16(fallback + "font_shadow");
- u32 font_shadow_alpha = g_settings->getU16(fallback + "font_shadow_alpha");
- font = gui::CGUITTFont::createTTFont(guienv,
- font_path.c_str(), font_size, true, true,
- font_shadow, font_shadow_alpha);
- } else {
- font = guienv->getFont(font_path.c_str());
- }
-#else
- font = guienv->getFont(font_path.c_str());
-#endif
- if (font)
- skin->setFont(font);
- else
- errorstream << "WARNING: Font file was not found. Using default font."
- << std::endl;
-
- font = skin->getFont(); // If font was not found, this will get us one
- assert(font);
-
- u32 text_height = font->getDimension(L"Hello, world!").Height;
- infostream << "text_height=" << text_height << std::endl;
-
skin->setColor(gui::EGDC_BUTTON_TEXT, video::SColor(255, 255, 255, 255));
skin->setColor(gui::EGDC_3D_HIGH_LIGHT, video::SColor(255, 0, 0, 0));
skin->setColor(gui::EGDC_3D_SHADOW, video::SColor(255, 0, 0, 0));
skin->setColor(gui::EGDC_HIGH_LIGHT, video::SColor(255, 70, 100, 50));
skin->setColor(gui::EGDC_HIGH_LIGHT_TEXT, video::SColor(255, 255, 255, 255));
+ glb_fontengine = new FontEngine(g_settings, guienv);
+ assert(glb_fontengine != NULL);
+
#if (IRRLICHT_VERSION_MAJOR >= 1 && IRRLICHT_VERSION_MINOR >= 8) || IRRLICHT_VERSION_MAJOR >= 2
// Irrlicht 1.8 input colours
skin->setColor(gui::EGDC_EDITABLE, video::SColor(255, 128, 128, 128));
@@ -1764,7 +1728,6 @@ bool ClientLauncher::run(GameParams &game_params, const Settings &cmd_args)
random_input,
input,
device,
- font,
worldspec.path,
current_playername,
current_password,