diff --git a/minetest.conf.example b/minetest.conf.example index 91b3251c0..5ab98c0f9 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -216,7 +216,7 @@ #tooltip_show_delay = 400 # Delay showing tooltips, in miliseconds #screen_dpi = 72 -# adjust dpi configuration to your screen (PC/MAC only) e.g. for 4k screens +# adjust dpi configuration to your screen (Desktop only) e.g. for 4k screens # Default timeout for cURL, in milliseconds # Only has an effect if compiled with cURL diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index a8ae9e251..1ebf5dc49 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -195,7 +195,7 @@ void set_default_settings(Settings *settings) settings->setDefault("mono_font_size", fontsize.str()); settings->setDefault("fallback_font_size", fontsize.str()); #else - settings->setDefault("freetype", "false"); + settings->setDefault("freetype", "false"); settings->setDefault("font_path", porting::getDataPath("fonts" DIR_DELIM "lucida_sans")); settings->setDefault("mono_font_path", porting::getDataPath("fonts" DIR_DELIM "mono_dejavu_sans")); diff --git a/src/drawscene.cpp b/src/drawscene.cpp index ba3316143..8ba2be1b0 100644 --- a/src/drawscene.cpp +++ b/src/drawscene.cpp @@ -507,7 +507,7 @@ void draw_load_screen(const std::wstring &text, IrrlichtDevice* device, video::IVideoDriver* driver = device->getVideoDriver(); v2u32 screensize = porting::getWindowSize(); - v2s32 textsize(glb_fontengine->getTextWidth(text), glb_fontengine->getLineHeight()); + v2s32 textsize(g_fontengine->getTextWidth(text), g_fontengine->getLineHeight()); v2s32 center(screensize.X / 2, screensize.Y / 2); core::rect textrect(center - textsize / 2, center + textsize / 2); @@ -534,7 +534,7 @@ void draw_load_screen(const std::wstring &text, IrrlichtDevice* device, // before with default settings 342 * porting::getDisplayDensity() * g_settings->getFloat("gui_scaling"), - glb_fontengine->getTextHeight() * 2); + g_fontengine->getTextHeight() * 2); core::rect barrect(center - barsize / 2, center + barsize / 2); driver->draw2DRectangle(video::SColor(255, 255, 255, 255),barrect, NULL); // border diff --git a/src/fontengine.cpp b/src/fontengine.cpp index c1e36d6c8..f73f47ff7 100644 --- a/src/fontengine.cpp +++ b/src/fontengine.cpp @@ -33,11 +33,11 @@ with this program; if not, write to the Free Software Foundation, Inc., #define MAX_FONT_SIZE_OFFSET 10 /** reference to access font engine, has to be initialized by main */ -FontEngine* glb_fontengine = NULL; +FontEngine* g_fontengine = NULL; /** callback to be used on change of font size setting */ static void font_setting_changed(const std::string) { - glb_fontengine->readSettings(); + g_fontengine->readSettings(); } /******************************************************************************/ @@ -349,7 +349,6 @@ void FontEngine::initFont(unsigned int basesize, FontMode mode) font_shadow_alpha); if (font != NULL) { - font->grab(); m_font_cache[mode][basesize] = font; } else { @@ -457,7 +456,6 @@ void FontEngine::initSimpleFont(unsigned int basesize, FontMode mode) } if (font != NULL) { - font->grab(); m_font_cache[mode][basesize] = font; } } diff --git a/src/fontengine.h b/src/fontengine.h index 6a5339770..679a96bea 100644 --- a/src/fontengine.h +++ b/src/fontengine.h @@ -135,6 +135,6 @@ private: }; /** interface to access main font engine*/ -extern FontEngine* glb_fontengine; +extern FontEngine* g_fontengine; #endif diff --git a/src/game.cpp b/src/game.cpp index c2b53420e..b6f96acc3 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -1159,7 +1159,7 @@ static void updateChat(Client &client, f32 dtime, bool show_debug, // Display all messages in a static text element unsigned int recent_chat_count = chat_backend.getRecentBuffer().getLineCount(); std::wstring recent_chat = chat_backend.getRecentChat(); - unsigned int line_height = glb_fontengine->getLineHeight(); + unsigned int line_height = g_fontengine->getLineHeight(); guitext_chat->setText(recent_chat.c_str()); @@ -1170,7 +1170,7 @@ static void updateChat(Client &client, f32 dtime, bool show_debug, chat_y += line_height; // first pass to calculate height of text to be set - s32 width = std::min(glb_fontengine->getTextWidth(recent_chat) + 10, + s32 width = std::min(g_fontengine->getTextWidth(recent_chat) + 10, porting::getWindowSize().X - 20); core::rect rect(10, chat_y, width, chat_y + porting::getWindowSize().Y); guitext_chat->setRelativePosition(rect); @@ -1923,7 +1923,7 @@ bool Game::createClient(const std::string &playername, } // Update cached textures, meshes and materials - client->afterContentReceived(device, glb_fontengine->getFont()); + client->afterContentReceived(device, g_fontengine->getFont()); /* Camera */ @@ -1981,8 +1981,7 @@ bool Game::createClient(const std::string &playername, player->hurt_tilt_timer = 0; player->hurt_tilt_strength = 0; - hud = new Hud(driver, smgr, guienv, glb_fontengine->getFont(), - glb_fontengine->getTextHeight(), gamedef, player, local_inventory); + hud = new Hud(driver, smgr, guienv, gamedef, player, local_inventory); if (!hud) { *error_message = L"Memory error: could not create HUD"; @@ -2011,7 +2010,7 @@ bool Game::initGui(std::wstring *error_message) // Object infos are shown in this guitext_info = guienv->addStaticText( L"", - core::rect(0, 0, 400, glb_fontengine->getTextHeight() * 5 + 5) + v2s32(100, 200), + core::rect(0, 0, 400, g_fontengine->getTextHeight() * 5 + 5) + v2s32(100, 200), false, true, guiroot); // Status text (displays info when showing and hiding GUI stuff, etc.) @@ -2342,7 +2341,7 @@ void Game::updateProfilers(const GameRunData &run_data, const RunStats &stats, g_profiler->print(infostream); } - update_profiler_gui(guitext_profiler, glb_fontengine, + update_profiler_gui(guitext_profiler, g_fontengine, run_data.profiler_current_page, run_data.profiler_max_page); g_profiler->clear(); @@ -2753,7 +2752,7 @@ void Game::toggleProfiler(float *statustext_time, u32 *profiler_current_page, *profiler_current_page = (*profiler_current_page + 1) % (profiler_max_page + 1); // FIXME: This updates the profiler with incomplete values - update_profiler_gui(guitext_profiler, glb_fontengine, *profiler_current_page, + update_profiler_gui(guitext_profiler, g_fontengine, *profiler_current_page, profiler_max_page); if (*profiler_current_page != 0) { @@ -3872,7 +3871,7 @@ void Game::updateFrame(std::vector &highlight_boxes, Profiler graph */ if (flags.show_profiler_graph) - graph->draw(10, screensize.Y - 10, driver, glb_fontengine->getFont()); + graph->draw(10, screensize.Y - 10, driver, g_fontengine->getFont()); /* Damage flash @@ -3955,7 +3954,7 @@ void Game::updateGui(float *statustext_time, const RunStats& stats, if (guitext->isVisible()) { core::rect rect( 5, 5, - screensize.X, 5 + glb_fontengine->getTextHeight() + screensize.X, 5 + g_fontengine->getTextHeight() ); guitext->setRelativePosition(rect); } @@ -3973,8 +3972,8 @@ void Game::updateGui(float *statustext_time, const RunStats& stats, guitext2->setVisible(true); core::rect rect( - 5, 5 + glb_fontengine->getTextHeight(), - screensize.X, 5 + glb_fontengine->getTextHeight() * 2 + 5, 5 + g_fontengine->getTextHeight(), + screensize.X, 5 + g_fontengine->getTextHeight() * 2 ); guitext2->setRelativePosition(rect); } else { diff --git a/src/guiChatConsole.cpp b/src/guiChatConsole.cpp index c9f41c76f..62ce0d1e1 100644 --- a/src/guiChatConsole.cpp +++ b/src/guiChatConsole.cpp @@ -92,7 +92,7 @@ GUIChatConsole::GUIChatConsole( m_background_color.setBlue(255); } - m_font = glb_fontengine->getFont(FONT_SIZE_UNSPECIFIED, FM_Mono); + m_font = g_fontengine->getFont(FONT_SIZE_UNSPECIFIED, FM_Mono); if (m_font == NULL) { diff --git a/src/guiEngine.cpp b/src/guiEngine.cpp index e941003fa..814a7504a 100644 --- a/src/guiEngine.cpp +++ b/src/guiEngine.cpp @@ -174,7 +174,7 @@ GUIEngine::GUIEngine( irr::IrrlichtDevice* dev, std::wstring t = narrow_to_wide(std::string("Minetest ") + minetest_version_hash); - core::rect rect(0, 0, glb_fontengine->getTextWidth(t), glb_fontengine->getTextHeight()); + core::rect rect(0, 0, g_fontengine->getTextWidth(t), g_fontengine->getTextHeight()); rect += v2s32(4, 0); m_irr_toplefttext = @@ -260,14 +260,14 @@ void GUIEngine::run() cloudInit(); - unsigned int text_height = glb_fontengine->getTextHeight(); + unsigned int text_height = g_fontengine->getTextHeight(); while(m_device->run() && (!m_startgame) && (!m_kill)) { //check if we need to update the "upper left corner"-text - if (text_height != glb_fontengine->getTextHeight()) { + if (text_height != g_fontengine->getTextHeight()) { updateTopLeftTextSize(); - text_height = glb_fontengine->getTextHeight(); + text_height = g_fontengine->getTextHeight(); } driver->beginScene(true, true, video::SColor(255,140,186,250)); @@ -590,7 +590,7 @@ void GUIEngine::updateTopLeftTextSize() { std::wstring text = m_irr_toplefttext->getText(); - core::rect rect(0, 0, glb_fontengine->getTextWidth(text), glb_fontengine->getTextHeight()); + core::rect rect(0, 0, g_fontengine->getTextWidth(text), g_fontengine->getTextHeight()); rect += v2s32(4, 0); m_irr_toplefttext->remove(); diff --git a/src/guiFormSpecMenu.cpp b/src/guiFormSpecMenu.cpp index c81238a65..0a7a82399 100644 --- a/src/guiFormSpecMenu.cpp +++ b/src/guiFormSpecMenu.cpp @@ -91,11 +91,11 @@ static gui::IGUIFont *select_font_by_line_height(double target_line_height) unsigned int hireq = ceil(target_line_height / porting::getDisplayDensity() / g_settings->getFloat("gui_scaling")); - unsigned int lohgt = font_line_height(glb_fontengine->getFont(loreq)); - unsigned int hihgt = font_line_height(glb_fontengine->getFont(hireq)); + unsigned int lohgt = font_line_height(g_fontengine->getFont(loreq)); + unsigned int hihgt = font_line_height(g_fontengine->getFont(hireq)); while(hireq - loreq > 1 && lohgt != hihgt) { unsigned int nureq = (loreq + hireq) >> 1; - unsigned int nuhgt = font_line_height(glb_fontengine->getFont(nureq)); + unsigned int nuhgt = font_line_height(g_fontengine->getFont(nureq)); if(nuhgt < target_line_height) { loreq = nureq; lohgt = nuhgt; @@ -104,7 +104,7 @@ static gui::IGUIFont *select_font_by_line_height(double target_line_height) hihgt = nuhgt; } } - return glb_fontengine->getFont(target_line_height - lohgt < hihgt - target_line_height ? loreq : hireq); + return g_fontengine->getFont(target_line_height - lohgt < hihgt - target_line_height ? loreq : hireq); } GUIFormSpecMenu::GUIFormSpecMenu(irr::IrrlichtDevice* dev, @@ -1992,7 +1992,7 @@ void GUIFormSpecMenu::regenerateGui(v2u32 screensize) // Non-size[] form must consist only of text fields and // implicit "Proceed" button. Use default font, and // temporary form size which will be recalculated below. - m_font = glb_fontengine->getFont(); + m_font = g_fontengine->getFont(); m_btn_height = font_line_height(m_font) * 0.875; DesiredRect = core::rect( mydata.screensize.X/2 - 580/2, diff --git a/src/hud.cpp b/src/hud.cpp index 02071835f..eb2dca573 100644 --- a/src/hud.cpp +++ b/src/hud.cpp @@ -31,6 +31,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "localplayer.h" #include "camera.h" #include "porting.h" +#include "fontengine.h" #include #ifdef HAVE_TOUCHSCREENGUI @@ -38,14 +39,11 @@ with this program; if not, write to the Free Software Foundation, Inc., #endif Hud::Hud(video::IVideoDriver *driver, scene::ISceneManager* smgr, - gui::IGUIEnvironment* guienv, gui::IGUIFont *font, - u32 text_height, IGameDef *gamedef, - LocalPlayer *player, Inventory *inventory) { + gui::IGUIEnvironment* guienv, IGameDef *gamedef, LocalPlayer *player, + Inventory *inventory) { this->driver = driver; this->smgr = smgr; this->guienv = guienv; - this->font = font; - this->text_height = text_height; this->gamedef = gamedef; this->player = player; this->inventory = inventory; @@ -156,7 +154,7 @@ void Hud::drawItem(const ItemStack &item, const core::rect& rect, bool sele video::SColor bgcolor2(128, 0, 0, 0); if (!use_hotbar_image) driver->draw2DRectangle(bgcolor2, rect, NULL); - drawItemStack(driver, font, item, rect, NULL, gamedef); + drawItemStack(driver, g_fontengine->getFont(), item, rect, NULL, gamedef); } //NOTE: selectitem = 0 -> no selected; selectitem 1-based @@ -240,6 +238,8 @@ void Hud::drawItems(v2s32 upperleftpos, s32 itemcount, s32 offset, void Hud::drawLuaElements(v3s16 camera_offset) { + uint32_t text_height = g_fontengine->getTextHeight(); + irr::gui::IGUIFont* font = g_fontengine->getFont(); for (size_t i = 0; i != player->maxHudId(); i++) { HudElement *e = player->getHud(i); if (!e) diff --git a/src/hud.h b/src/hud.h index 9969fce73..2e6838eb1 100644 --- a/src/hud.h +++ b/src/hud.h @@ -103,8 +103,6 @@ public: video::IVideoDriver *driver; scene::ISceneManager* smgr; gui::IGUIEnvironment *guienv; - gui::IGUIFont *font; - u32 text_height; IGameDef *gamedef; LocalPlayer *player; Inventory *inventory; @@ -120,9 +118,8 @@ public: v3s16 camera_offset; Hud(video::IVideoDriver *driver,scene::ISceneManager* smgr, - gui::IGUIEnvironment* guienv, gui::IGUIFont *font, - u32 text_height, IGameDef *gamedef, - LocalPlayer *player, Inventory *inventory); + gui::IGUIEnvironment* guienv, IGameDef *gamedef, LocalPlayer *player, + Inventory *inventory); void drawHotbar(u16 playeritem); void resizeHotbar(); diff --git a/src/main.cpp b/src/main.cpp index 7141bec66..d9fa8faa2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1569,8 +1569,8 @@ ClientLauncher::~ClientLauncher() if (input) delete input; - if (glb_fontengine) - delete glb_fontengine; + if (g_fontengine) + delete g_fontengine; if (device) device->drop(); @@ -1630,8 +1630,8 @@ bool ClientLauncher::run(GameParams &game_params, const Settings &cmd_args) 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); + g_fontengine = new FontEngine(g_settings, guienv); + assert(g_fontengine != NULL); #if (IRRLICHT_VERSION_MAJOR >= 1 && IRRLICHT_VERSION_MINOR >= 8) || IRRLICHT_VERSION_MAJOR >= 2 // Irrlicht 1.8 input colours