#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 | |
unsigned int | getTextHeight (unsigned int font_size=FONT_SIZE_UNSPECIFIED, FontMode mode=FM_Unspecified) |
get text width if a text for a specific font | |
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 | |
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) | |
unsigned int | getLineHeight (unsigned int font_size=FONT_SIZE_UNSPECIFIED, FontMode mode=FM_Unspecified) |
unsigned int | getDefaultFontSize () |
get default font size | |
unsigned int | getFontSize (FontMode mode) |
get font size for a specific mode | |
void | readSettings () |
update internal parameters from settings | |
Private Member Functions | |
irr::gui::IGUIFont * | getFont (FontSpec spec, bool may_fail) |
void | updateFontCache () |
update content of font cache in case of a setting change made it invalid | |
gui::IGUIFont * | initFont (const FontSpec &spec) |
initialize a new TTF font | |
void | updateSkin () |
update current minetest skin with font changes | |
void | cleanCache () |
clean cache | |
DISABLE_CLASS_COPY (FontEngine) | |
Private Attributes | |
gui::IGUIEnvironment * | m_env = nullptr |
pointer to irrlicht gui environment | |
std::recursive_mutex | m_font_mutex |
mutex used to protect font init and cache | |
std::map< unsigned int, irr::gui::IGUIFont * > | m_font_cache [FM_MaxMode<< 2] |
internal storage for caching fonts of different size | |
unsigned int | m_default_size [FM_MaxMode] |
default font size to use | |
bool | m_default_bold = false |
default bold and italic | |
bool | m_default_italic = false |
Static Private Attributes | |
static const FontMode | m_currentMode = FM_Standard |
default font engine mode (fixed) | |
FontEngine::FontEngine | ( | gui::IGUIEnvironment * | env | ) |
References font_setting_changed(), FONT_SIZE_UNSPECIFIED, g_settings, m_default_size, m_env, readSettings(), Settings::registerChangedCallback(), and settings.
FontEngine::~FontEngine | ( | ) |
References cleanCache(), Settings::deregisterAllChangedCallbacks(), and g_settings.
|
private |
clean cache
References m_font_cache, and m_font_mutex.
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 getFont().
Referenced by GUIChatConsole::GUIChatConsole(), TextDrawer::draw(), Hud::drawItem(), Hud::drawLuaElements(), Camera::drawNametags(), Game::drawScene(), getFont(), getFont(), StyleSpec::getFont(), getLineHeight(), getTextHeight(), getTextWidth(), GameUI::init(), initFont(), GUIFormSpecMenu::regenerateGui(), GUIOpenURLMenu::regenerateGui(), ParsedText::Element::setStyle(), updateFontCache(), and updateSkin().
|
private |
References _FM_Fallback, FontSpec::bold, errorstream, FM_Unspecified, FONT_SIZE_UNSPECIFIED, FontSpec::getHash(), initFont(), FontSpec::italic, m_currentMode, m_default_size, m_font_cache, m_font_mutex, FontSpec::mode, and FontSpec::size.
|
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_Standard, FM_Unspecified, and m_default_size.
Referenced by StyleSpec::getFont(), and ParsedText::Element::setStyle().
unsigned int FontEngine::getLineHeight | ( | const FontSpec & | spec | ) |
get line height for a specific font (including empty room between lines)
References getFont().
Referenced by RenderingEngine::draw_load_screen(), and getLineHeight().
|
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 getFont().
Referenced by GUIEngine::GUIEngine(), GUIFormSpecMenu::createTextField(), Hud::drawLuaElements(), getTextHeight(), GameUI::init(), GUIFormSpecMenu::parsePwdField(), GUIEngine::run(), 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 getFont().
Referenced by GUIEngine::GUIEngine(), RenderingEngine::draw_load_screen(), getTextWidth(), getTextWidth(), 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 TTF font
References _FM_Fallback, FontSpec::bold, irr::gui::CGUITTFont::createTTFont(), errorstream, FM_Mono, FM_Unspecified, FONT_SIZE_UNSPECIFIED, g_settings, Settings::get(), RenderingEngine::getDisplayDensity(), Settings::getFloat(), getFont(), Settings::getLayer(), Settings::getU16(), Settings::getU16NoEx(), FontSpec::italic, m_env, FontSpec::mode, rangelim, sanity_check, FontSpec::size, and SL_DEFAULTS.
Referenced by getFont().
void FontEngine::readSettings | ( | ) |
update internal parameters from settings
References _FM_Fallback, cleanCache(), FM_Mono, FM_Standard, g_settings, Settings::getBool(), Settings::getU16(), m_default_bold, m_default_italic, m_default_size, rangelim, updateFontCache(), and updateSkin().
Referenced by FontEngine().
|
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 getFont(), and m_env.
Referenced by readSettings().
|
staticprivate |
default font engine mode (fixed)
Referenced by getDefaultFontSize(), and getFont().
|
private |
default bold and italic
Referenced by getFont(), getLineHeight(), getTextHeight(), getTextWidth(), getTextWidth(), and readSettings().
|
private |
Referenced by getFont(), getLineHeight(), getTextHeight(), getTextWidth(), 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(), initFont(), and updateSkin().
|
private |
internal storage for caching fonts of different size
Referenced by cleanCache(), and getFont().
|
private |
mutex used to protect font init and cache
Referenced by cleanCache(), and getFont().