Minetest  5.4.0
FontEngine Class Reference

#include <fontengine.h>

+ Collaboration diagram for FontEngine:

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...
 

Constructor & Destructor Documentation

◆ FontEngine()

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().

+ Here is the call graph for this function:

◆ ~FontEngine()

FontEngine::~FontEngine ( )

References cleanCache().

+ Here is the call graph for this function:

Member Function Documentation

◆ cleanCache()

void FontEngine::cleanCache ( )
private

clean cache

References m_font_cache.

Referenced by ~FontEngine(), and readSettings().

+ Here is the caller graph for this function:

◆ DISABLE_CLASS_COPY()

FontEngine::DISABLE_CLASS_COPY ( FontEngine  )
private

◆ getDefaultFontSize()

unsigned int FontEngine::getDefaultFontSize ( )

get default font size

References m_currentMode, and m_default_size.

Referenced by Hud::drawLuaElements(), and GameUI::init().

+ Here is the caller graph for this function:

◆ getFont() [1/2]

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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFont() [2/2]

irr::gui::IGUIFont* FontEngine::getFont ( unsigned int  font_size = FONT_SIZE_UNSPECIFIED,
FontMode  mode = FM_Unspecified 
)
inline

References getFont(), m_default_bold, and m_default_italic.

+ Here is the call graph for this function:

◆ getFontSize()

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().

+ Here is the caller graph for this function:

◆ getLineHeight() [1/2]

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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLineHeight() [2/2]

unsigned int FontEngine::getLineHeight ( unsigned int  font_size = FONT_SIZE_UNSPECIFIED,
FontMode  mode = FM_Unspecified 
)
inline

References getLineHeight(), m_default_bold, and m_default_italic.

+ Here is the call graph for this function:

◆ getTextHeight() [1/2]

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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTextHeight() [2/2]

unsigned int FontEngine::getTextHeight ( unsigned int  font_size = FONT_SIZE_UNSPECIFIED,
FontMode  mode = FM_Unspecified 
)
inline

get text width if a text for a specific font

References getTextHeight(), m_default_bold, and m_default_italic.

+ Here is the call graph for this function:

◆ getTextWidth() [1/4]

unsigned int FontEngine::getTextWidth ( const std::string &  text,
const FontSpec spec 
)
inline

References getTextWidth(), and utf8_to_wide().

+ Here is the call graph for this function:

◆ getTextWidth() [2/4]

unsigned int FontEngine::getTextWidth ( const std::string &  text,
unsigned int  font_size = FONT_SIZE_UNSPECIFIED,
FontMode  mode = FM_Unspecified 
)
inline

References getTextWidth(), m_default_bold, m_default_italic, and utf8_to_wide().

+ Here is the call graph for this function:

◆ getTextWidth() [3/4]

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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTextWidth() [4/4]

unsigned int FontEngine::getTextWidth ( const std::wstring &  text,
unsigned int  font_size = FONT_SIZE_UNSPECIFIED,
FontMode  mode = FM_Unspecified 
)
inline

get text width if a text for a specific font

References getTextWidth(), m_default_bold, and m_default_italic.

+ Here is the call graph for this function:

◆ initFont()

gui::IGUIFont * FontEngine::initFont ( const FontSpec spec)
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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initSimpleFont()

gui::IGUIFont * FontEngine::initSimpleFont ( const FontSpec spec)
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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readSettings()

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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateFontCache()

void FontEngine::updateFontCache ( )
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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateSkin()

void FontEngine::updateSkin ( )
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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_currentMode

FontMode FontEngine::m_currentMode = FM_Standard
private

current font engine mode

Referenced by FontEngine(), getDefaultFontSize(), getFont(), getFontSize(), and readSettings().

◆ m_default_bold

bool FontEngine::m_default_bold = false
private

default bold and italic

Referenced by getFont(), getLineHeight(), getTextHeight(), getTextWidth(), and readSettings().

◆ m_default_italic

bool FontEngine::m_default_italic = false
private

◆ m_default_size

unsigned int FontEngine::m_default_size[FM_MaxMode]
private

default font size to use

Referenced by FontEngine(), getDefaultFontSize(), getFont(), getFontSize(), and readSettings().

◆ m_env

gui::IGUIEnvironment* FontEngine::m_env = nullptr
private

pointer to irrlicht gui environment

Referenced by FontEngine(), getLineHeight(), getTextHeight(), getTextWidth(), initFont(), initSimpleFont(), and updateSkin().

◆ m_font_cache

std::map<unsigned int, irr::gui::IGUIFont*> FontEngine::m_font_cache[FM_MaxMode<< 2]
private

internal storage for caching fonts of different size

Referenced by cleanCache(), and getFont().


The documentation for this class was generated from the following files: