]> git.lizzy.rs Git - minetest.git/blobdiff - src/fontengine.h
Drop texture file list cache (#6660)
[minetest.git] / src / fontengine.h
index 6a53397707a7cace65c7cd022201c68e8698070b..a75618f8600f296807813b69611fce752b2cc2c8 100644 (file)
@@ -16,14 +16,15 @@ You should have received a copy of the GNU Lesser General Public License along
 with this program; if not, write to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
-#ifndef __FONTENGINE_H__
-#define __FONTENGINE_H__
+
+#pragma once
 
 #include <map>
 #include <vector>
-#include "IGUIFont.h"
-#include "IGUISkin.h"
-#include "IGUIEnvironment.h"
+#include "util/basic_macros.h"
+#include <IGUIFont.h>
+#include <IGUISkin.h>
+#include <IGUIEnvironment.h>
 #include "settings.h"
 
 #define FONT_SIZE_UNSPECIFIED 0xFFFFFFFF
@@ -59,7 +60,7 @@ class FontEngine
                        unsigned int font_size=FONT_SIZE_UNSPECIFIED,
                        FontMode mode=FM_Unspecified)
        {
-               return getTextWidth(narrow_to_wide(text));
+               return getTextWidth(utf8_to_wide(text));
        }
 
        /** get text width if a text for a specific font */
@@ -81,18 +82,6 @@ class FontEngine
        void readSettings();
 
 private:
-       /** disable copy constructor */
-       FontEngine() :
-               m_settings(NULL),
-               m_env(NULL),
-               m_font_cache(),
-               m_default_size(),
-               m_currentMode(FM_Standard),
-               m_lastMode(),
-               m_lastSize(0),
-               m_lastFont(NULL)
-       {};
-
        /** update content of font cache in case of a setting change made it invalid */
        void updateFontCache();
 
@@ -109,10 +98,10 @@ class FontEngine
        void cleanCache();
 
        /** pointer to settings for registering callbacks or reading config */
-       Settings* m_settings;
+       Settings* m_settings = nullptr;
 
        /** pointer to irrlicht gui environment */
-       gui::IGUIEnvironment* m_env;
+       gui::IGUIEnvironment* m_env = nullptr;
 
        /** internal storage for caching fonts of different size */
        std::map<unsigned int, irr::gui::IGUIFont*> m_font_cache[FM_MaxMode];
@@ -121,20 +110,19 @@ class FontEngine
        unsigned int m_default_size[FM_MaxMode];
 
        /** current font engine mode */
-       FontMode m_currentMode;
+       FontMode m_currentMode = FM_Standard;
 
        /** font mode of last request */
        FontMode m_lastMode;
 
        /** size of last request */
-       unsigned int m_lastSize;
+       unsigned int m_lastSize = 0;
 
        /** last font returned */
-       irr::gui::IGUIFont* m_lastFont;
+       irr::gui::IGUIFont* m_lastFont = nullptr;
 
+       DISABLE_CLASS_COPY(FontEngine);
 };
 
 /** interface to access main font engine*/
-extern FontEngine* glb_fontengine;
-
-#endif
+extern FontEngine* g_fontengine;