#include <fontengine.h>
Public Member Functions | |
FontEngine (gui::IGUIEnvironment *env) | |
~FontEngine () | |
irr::gui::IGUIFont * | getFont (FontSpec spec) |
irr::gui::IGUIFont * | getFont (unsigned int font_size=FONT_SIZE_UNSPECIFIED, FontMode mode=FM_Unspecified) |
unsigned int | getTextHeight (const FontSpec &spec) |
get text height for a specific font More... | |
unsigned int | getTextHeight (unsigned int font_size=FONT_SIZE_UNSPECIFIED, FontMode mode=FM_Unspecified) |
get text width if a text for a specific font More... | |
unsigned int | getTextWidth (const std::wstring &text, const FontSpec &spec) |
unsigned int | getTextWidth (const std::wstring &text, unsigned int font_size=FONT_SIZE_UNSPECIFIED, FontMode mode=FM_Unspecified) |
get text width if a text for a specific font More... | |
unsigned int | getTextWidth (const std::string &text, const FontSpec &spec) |
unsigned int | getTextWidth (const std::string &text, unsigned int font_size=FONT_SIZE_UNSPECIFIED, FontMode mode=FM_Unspecified) |
unsigned int | getLineHeight (const FontSpec &spec) |
get line height for a specific font (including empty room between lines) More... | |
unsigned int | getLineHeight (unsigned int font_size=FONT_SIZE_UNSPECIFIED, FontMode mode=FM_Unspecified) |
unsigned int | getDefaultFontSize () |
get default font size More... | |
unsigned int | getFontSize (FontMode mode) |
get font size for a specific mode More... | |
void | readSettings () |
update internal parameters from settings More... | |
Private Member Functions | |
void | updateFontCache () |
update content of font cache in case of a setting change made it invalid More... | |
gui::IGUIFont * | initFont (const FontSpec &spec) |
initialize a new font More... | |
gui::IGUIFont * | initSimpleFont (const FontSpec &spec) |
initialize a font without freetype More... | |
void | updateSkin () |
update current minetest skin with font changes More... | |
void | cleanCache () |
clean cache More... | |
DISABLE_CLASS_COPY (FontEngine) | |
Private Attributes | |
gui::IGUIEnvironment * | m_env = nullptr |
pointer to irrlicht gui environment More... | |
std::map< unsigned int, irr::gui::IGUIFont * > | m_font_cache [FM_MaxMode<< 2] |
internal storage for caching fonts of different size More... | |
unsigned int | m_default_size [FM_MaxMode] |
default font size to use More... | |
bool | m_default_bold = false |
default bold and italic More... | |
bool | m_default_italic = false |
FontMode | m_currentMode = FM_Standard |
current font engine mode More... | |
FontEngine::FontEngine | ( | gui::IGUIEnvironment * | env | ) |
References FM_Fallback, FM_Standard, font_setting_changed(), FONT_SIZE_UNSPECIFIED, g_settings, m_currentMode, m_default_size, m_env, readSettings(), and Settings::registerChangedCallback().
FontEngine::~FontEngine | ( | ) |
|
private |
clean cache
References m_font_cache.
Referenced by ~FontEngine(), and readSettings().
|
private |
unsigned int FontEngine::getDefaultFontSize | ( | ) |
get default font size
References m_currentMode, and m_default_size.
Referenced by Hud::drawLuaElements(), and GameUI::init().
irr::gui::IGUIFont * FontEngine::getFont | ( | FontSpec | spec | ) |
References FontSpec::bold, FM_Mono, FM_Simple, FM_SimpleMono, FM_Unspecified, FONT_SIZE_UNSPECIFIED, FontSpec::getHash(), initFont(), initSimpleFont(), FontSpec::italic, m_currentMode, m_default_size, m_font_cache, FontSpec::mode, and FontSpec::size.
Referenced by GUIChatConsole::GUIChatConsole(), TextDrawer::draw(), Hud::drawItem(), Hud::drawLuaElements(), Camera::drawNametags(), StyleSpec::getFont(), getFont(), getLineHeight(), getTextHeight(), getTextWidth(), GameUI::init(), GUIFormSpecMenu::regenerateGui(), ParsedText::Element::setStyle(), updateFontCache(), Game::updateFrame(), and updateSkin().
|
inline |
References getFont(), m_default_bold, and m_default_italic.
unsigned int FontEngine::getFontSize | ( | FontMode | mode | ) |
get font size for a specific mode
References FM_Mono, FM_Simple, FM_SimpleMono, FM_Standard, FM_Unspecified, m_currentMode, and m_default_size.
Referenced by StyleSpec::getFont().
unsigned int FontEngine::getLineHeight | ( | const FontSpec & | spec | ) |
get line height for a specific font (including empty room between lines)
References FATAL_ERROR_IF, getFont(), and m_env.
Referenced by RenderingEngine::_draw_load_screen(), getLineHeight(), and GameUI::setChatText().
|
inline |
References getLineHeight(), m_default_bold, and m_default_italic.
unsigned int FontEngine::getTextHeight | ( | const FontSpec & | spec | ) |
get text height for a specific font
References FATAL_ERROR_IF, getFont(), and m_env.
Referenced by GUIEngine::GUIEngine(), GUIFormSpecMenu::createTextField(), Hud::drawLuaElements(), getTextHeight(), GameUI::init(), GUIFormSpecMenu::parsePwdField(), GUIEngine::run(), GameUI::update(), and GUIEngine::updateTopLeftTextSize().
|
inline |
get text width if a text for a specific font
References getTextHeight(), m_default_bold, and m_default_italic.
|
inline |
|
inline |
References getTextWidth(), m_default_bold, m_default_italic, and utf8_to_wide().
unsigned int FontEngine::getTextWidth | ( | const std::wstring & | text, |
const FontSpec & | spec | ||
) |
References FATAL_ERROR_IF, getFont(), and m_env.
Referenced by GUIEngine::GUIEngine(), RenderingEngine::_draw_load_screen(), getTextWidth(), and GUIEngine::updateTopLeftTextSize().
|
inline |
get text width if a text for a specific font
References getTextWidth(), m_default_bold, and m_default_italic.
|
private |
initialize a new font
References FontSpec::bold, errorstream, FM_Fallback, FM_Mono, FM_SimpleMono, FM_Unspecified, FONT_SIZE_UNSPECIFIED, g_settings, Settings::get(), RenderingEngine::getDisplayDensity(), Settings::getFloat(), Settings::getLayer(), Settings::getU16NoEx(), FontSpec::italic, m_env, FontSpec::mode, FontSpec::size, and SL_DEFAULTS.
Referenced by getFont().
|
private |
initialize a font without freetype
References errorstream, FM_Simple, FM_SimpleMono, FONT_SIZE_UNSPECIFIED, g_settings, Settings::get(), RenderingEngine::getDisplayDensity(), Settings::getFloat(), lowercase(), m_env, MAX_FONT_SIZE_OFFSET, FontSpec::mode, fs::PathExists(), FontSpec::size, and verbosestream.
Referenced by getFont().
void FontEngine::readSettings | ( | ) |
update internal parameters from settings
References cleanCache(), FM_Fallback, FM_Mono, FM_Simple, FM_SimpleMono, FM_Standard, g_settings, Settings::getBool(), Settings::getU16(), is_yes(), m_currentMode, m_default_bold, m_default_italic, m_default_size, updateFontCache(), updateSkin(), and USE_FREETYPE.
Referenced by FontEngine(), and font_setting_changed().
|
private |
update content of font cache in case of a setting change made it invalid
References FM_Unspecified, FONT_SIZE_UNSPECIFIED, and getFont().
Referenced by readSettings().
|
private |
update current minetest skin with font changes
References errorstream, FATAL_ERROR_IF, g_settings, Settings::get(), getFont(), infostream, and m_env.
Referenced by readSettings().
|
private |
current font engine mode
Referenced by FontEngine(), getDefaultFontSize(), getFont(), getFontSize(), and readSettings().
|
private |
default bold and italic
Referenced by getFont(), getLineHeight(), getTextHeight(), getTextWidth(), and readSettings().
|
private |
Referenced by getFont(), getLineHeight(), getTextHeight(), getTextWidth(), and readSettings().
|
private |
default font size to use
Referenced by FontEngine(), getDefaultFontSize(), getFont(), getFontSize(), and readSettings().
|
private |
pointer to irrlicht gui environment
Referenced by FontEngine(), getLineHeight(), getTextHeight(), getTextWidth(), initFont(), initSimpleFont(), and updateSkin().
|
private |
internal storage for caching fonts of different size
Referenced by cleanCache(), and getFont().