Luanti 5.11.0-dev
 
Loading...
Searching...
No Matches
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
 
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)
 

Constructor & Destructor Documentation

◆ FontEngine()

FontEngine::FontEngine ( gui::IGUIEnvironment * env)

References font_setting_changed(), FONT_SIZE_UNSPECIFIED, g_settings, m_default_size, m_env, readSettings(), Settings::registerChangedCallback(), and settings.

+ Here is the call graph for this function:

◆ ~FontEngine()

FontEngine::~FontEngine ( )

References cleanCache(), Settings::deregisterAllChangedCallbacks(), and g_settings.

+ Here is the call graph for this function:

Member Function Documentation

◆ cleanCache()

void FontEngine::cleanCache ( )
private

clean cache

References m_font_cache, and m_font_mutex.

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/3]

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

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

◆ getFont() [2/3]

irr::gui::IGUIFont * FontEngine::getFont ( FontSpec spec,
bool may_fail )
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.

+ Here is the call graph for this function:

◆ getFont() [3/3]

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_Standard, FM_Unspecified, and m_default_size.

Referenced by StyleSpec::getFont(), and ParsedText::Element::setStyle().

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

Referenced by RenderingEngine::draw_load_screen(), and getLineHeight().

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

Referenced by GUIEngine::GUIEngine(), GUIFormSpecMenu::createTextField(), Hud::drawLuaElements(), getTextHeight(), GameUI::init(), GUIFormSpecMenu::parsePwdField(), GUIEngine::run(), 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 getFont().

Referenced by GUIEngine::GUIEngine(), RenderingEngine::draw_load_screen(), getTextWidth(), getTextWidth(), 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 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().

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

+ 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 getFont(), 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

const FontMode FontEngine::m_currentMode = FM_Standard
staticprivate

default font engine mode (fixed)

Referenced by getDefaultFontSize(), and getFont().

◆ m_default_bold

bool FontEngine::m_default_bold = false
private

default bold and italic

Referenced by getFont(), getLineHeight(), getTextHeight(), getTextWidth(), 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(), initFont(), 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().

◆ m_font_mutex

std::recursive_mutex FontEngine::m_font_mutex
private

mutex used to protect font init and cache

Referenced by cleanCache(), and getFont().


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