OpenTTD Source 20260211-master-g04436b7401
FreeTypeFontCacheFactory Class Reference
Inheritance diagram for FreeTypeFontCacheFactory:
FontCacheFactory BaseProvider< FontCacheFactory >

Public Member Functions

std::unique_ptr< FontCacheLoadFont (FontSize fs, FontType fonttype) const override
 Loads the freetype font.
bool FindFallbackFont (struct FontCacheSettings *settings, const std::string &language_isocode, class MissingGlyphSearcher *callback) const override
 We would like to have a fallback font as the current one doesn't contain all characters we need.
Public Member Functions inherited from FontCacheFactory
 FontCacheFactory (std::string_view name, std::string_view description)
Public Member Functions inherited from BaseProvider< FontCacheFactory >
constexpr BaseProvider (std::string_view name, std::string_view description)
std::string_view GetName () const
std::string_view GetDescription () const

Static Private Member Functions

static std::unique_ptr< FontCacheLoadFont (FontSize fs, FT_Face face, std::string_view font_name, uint size)

Static Private Attributes

static FreeTypeFontCacheFactory instance

Additional Inherited Members

Protected Attributes inherited from BaseProvider< FontCacheFactory >
const std::string_view name
const std::string_view description

Detailed Description

Definition at line 212 of file freetypefontcache.cpp.

Constructor & Destructor Documentation

◆ FreeTypeFontCacheFactory()

FreeTypeFontCacheFactory::FreeTypeFontCacheFactory ( )
inline

Definition at line 214 of file freetypefontcache.cpp.

◆ ~FreeTypeFontCacheFactory()

FreeTypeFontCacheFactory::~FreeTypeFontCacheFactory ( )
inlineoverride

Definition at line 216 of file freetypefontcache.cpp.

Member Function Documentation

◆ FindFallbackFont()

bool FreeTypeFontCacheFactory::FindFallbackFont ( struct FontCacheSettings * settings,
const std::string & language_isocode,
class MissingGlyphSearcher * callback ) const
inlineoverridevirtual

We would like to have a fallback font as the current one doesn't contain all characters we need.

This function must set all fonts of settings.

Parameters
settingsThe settings to overwrite the fontname of.
language_isocodeThe language, e.g. en_GB.
callbackThe function to call to check for missing glyphs.
Returns
true if a font has been set, false otherwise.

Implements FontCacheFactory.

Definition at line 277 of file freetypefontcache.cpp.

References settings.

◆ LoadFont() [1/2]

std::unique_ptr< FontCache > FreeTypeFontCacheFactory::LoadFont ( FontSize fs,
FontType fonttype ) const
inlineoverridevirtual

Loads the freetype font.

First try to load the fontname as if it were a path. If that fails, try to resolve the filename of the font using fontconfig, where the format is 'font family name' or 'font family name, font style'.

Parameters
fsThe font size to load.
fonttypeThe type of font that is requested to be loaded.
Returns
The loaded font, or nullptr when none could be loaded.

Implements FontCacheFactory.

Definition at line 231 of file freetypefontcache.cpp.

References BASE_DIR, Debug, FioFindFullPath(), GetFontByFaceName(), GetFontCacheFontName(), GetFontCacheFontSize(), GetFontCacheSubSetting(), LoadFont(), settings, and TrueType.

Referenced by LoadFont().

◆ LoadFont() [2/2]

std::unique_ptr< FontCache > FreeTypeFontCacheFactory::LoadFont ( FontSize fs,
FT_Face face,
std::string_view font_name,
uint size )
inlinestaticprivate

Definition at line 287 of file freetypefontcache.cpp.

Field Documentation

◆ instance

FreeTypeFontCacheFactory FreeTypeFontCacheFactory::instance
staticprivate

Definition at line 322 of file freetypefontcache.cpp.


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