diff options
author | Pierre-Yves Rollo <dev@pyrollo.com> | 2019-09-10 15:11:26 +0200 |
---|---|---|
committer | SmallJoker <SmallJoker@users.noreply.github.com> | 2019-11-03 11:45:33 +0100 |
commit | 72416a6a1f75d56abfad0f486e57fd32579b3604 (patch) | |
tree | 2ff2978c1aec4ee6548474b8c65d3c96bab5b05f /src/client/fontengine.h | |
parent | 8697090b3564b508af50d40068a61db280f714a6 (diff) | |
download | dragonfireclient-72416a6a1f75d56abfad0f486e57fd32579b3604.tar.xz |
Formspec: add hypertext element
Diffstat (limited to 'src/client/fontengine.h')
-rw-r--r-- | src/client/fontengine.h | 61 |
1 files changed, 51 insertions, 10 deletions
diff --git a/src/client/fontengine.h b/src/client/fontengine.h index 62aa71897..ecffc7660 100644 --- a/src/client/fontengine.h +++ b/src/client/fontengine.h @@ -48,29 +48,62 @@ public: ~FontEngine(); /** get Font */ - irr::gui::IGUIFont* getFont(unsigned int font_size=FONT_SIZE_UNSPECIFIED, - FontMode mode=FM_Unspecified); + irr::gui::IGUIFont *getFont(unsigned int font_size, FontMode mode, + bool bold, bool italic); + + irr::gui::IGUIFont *getFont(unsigned int font_size=FONT_SIZE_UNSPECIFIED, + FontMode mode=FM_Unspecified) + { + return getFont(font_size, mode, m_default_bold, m_default_italic); + } /** get text height for a specific font */ - unsigned int getTextHeight(unsigned int font_size=FONT_SIZE_UNSPECIFIED, - FontMode mode=FM_Unspecified); + unsigned int getTextHeight(unsigned int font_size, FontMode mode, + bool bold, bool italic); /** get text width if a text for a specific font */ - unsigned int getTextWidth(const std::string& text, + unsigned int getTextHeight( unsigned int font_size=FONT_SIZE_UNSPECIFIED, FontMode mode=FM_Unspecified) { - return getTextWidth(utf8_to_wide(text)); + return getTextHeight(font_size, mode, m_default_bold, m_default_italic); } + unsigned int getTextWidth(const std::wstring& text, + unsigned int font_size, FontMode mode, bool bold, bool italic); + /** get text width if a text for a specific font */ unsigned int getTextWidth(const std::wstring& text, unsigned int font_size=FONT_SIZE_UNSPECIFIED, - FontMode mode=FM_Unspecified); + FontMode mode=FM_Unspecified) + { + return getTextWidth(text, font_size, mode, m_default_bold, + m_default_italic); + } + + unsigned int getTextWidth(const std::string& text, + unsigned int font_size, FontMode mode, bool bold, bool italic) + { + return getTextWidth(utf8_to_wide(text), font_size, mode, bold, italic); + } + + unsigned int getTextWidth(const std::string& text, + unsigned int font_size=FONT_SIZE_UNSPECIFIED, + FontMode mode=FM_Unspecified) + { + return getTextWidth(utf8_to_wide(text), font_size, mode, m_default_bold, + m_default_italic); + } /** get line height for a specific font (including empty room between lines) */ + unsigned int getLineHeight(unsigned int font_size, FontMode mode, bool bold, + bool italic); + unsigned int getLineHeight(unsigned int font_size=FONT_SIZE_UNSPECIFIED, - FontMode mode=FM_Unspecified); + FontMode mode=FM_Unspecified) + { + return getLineHeight(font_size, mode, m_default_bold, m_default_italic); + } /** get default font size */ unsigned int getDefaultFontSize(); @@ -86,7 +119,11 @@ private: void updateFontCache(); /** initialize a new font */ - void initFont(unsigned int basesize, FontMode mode=FM_Unspecified); + void initFont( + unsigned int basesize, + FontMode mode, + bool bold, + bool italic); /** initialize a font without freetype */ void initSimpleFont(unsigned int basesize, FontMode mode); @@ -104,11 +141,15 @@ private: 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]; + std::map<unsigned int, irr::gui::IGUIFont*> m_font_cache[FM_MaxMode << 2]; /** default font size to use */ unsigned int m_default_size[FM_MaxMode]; + /** default bold and italic */ + bool m_default_bold; + bool m_default_italic; + /** current font engine mode */ FontMode m_currentMode = FM_Standard; |