OpenTTD Source 20260415-master-g3f4984ebaa
Win32FontCacheFactory Class Reference
Inheritance diagram for Win32FontCacheFactory:
FontCacheFactory

Public Member Functions

std::unique_ptr< FontCacheLoadFont (FontSize fs, FontType fonttype, bool search, const std::string &font_name, const std::any &os_handle) const override
 Try loading a font with this factory.
bool FindFallbackFont (const std::string &language_isocode, MissingGlyphSearcher *callback) const override
 We would like to have a fallback font as the current one doesn't contain all characters we need.

Static Private Member Functions

static std::unique_ptr< FontCacheLoadWin32Font (FontSize fs, const LOGFONT &logfont, uint size, std::string_view font_name)
static bool TryLoadFontFromFile (const std::string &font_name, LOGFONT &logfont)
 Try to load a font by filename.

Static Private Attributes

static Win32FontCacheFactory instance

Additional Inherited Members

Private Member Functions inherited from FontCacheFactory
 FontCacheFactory (std::string_view name, std::string_view description)
 ~FontCacheFactory () override
 Unregister this factory.
Private Member Functions inherited from BaseProvider< FontCacheFactory >
constexpr BaseProvider (std::string_view name, std::string_view description)
 Create the provider.
virtual ~BaseProvider ()=default
 Ensure the destructor of the sub classes are called as well.
std::string_view GetName () const
 Get the name of this provider.
std::string_view GetDescription () const
 Get a description of this provider.
Private Attributes inherited from BaseProvider< FontCacheFactory >
const std::string_view name
 The name of the provider.
const std::string_view description
 A description of the provider.

Detailed Description

Definition at line 269 of file font_win32.cpp.

Constructor & Destructor Documentation

◆ Win32FontCacheFactory()

Win32FontCacheFactory::Win32FontCacheFactory ( )
inline

Definition at line 271 of file font_win32.cpp.

Member Function Documentation

◆ FindFallbackFont()

bool Win32FontCacheFactory::FindFallbackFont ( const std::string & language_isocode,
MissingGlyphSearcher * callback ) const
inlineoverridevirtual

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

Parameters
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 303 of file font_win32.cpp.

References Debug, and OTTD2FS().

◆ LoadFont()

std::unique_ptr< FontCache > Win32FontCacheFactory::LoadFont ( FontSize fs,
FontType fonttype,
bool search,
const std::string & font_name,
const std::any & os_handle ) const
inlineoverridevirtual

Try loading a font with this factory.

Parameters
fsFont size to load.
fonttypeFont type requested.
searchSet if searching for the font.
font_nameFont name to load.
os_handleFont handle to load.
Returns
FontCache of the font if loaded, or nullptr.

Implements FontCacheFactory.

Definition at line 273 of file font_win32.cpp.

References convert_to_fs(), GetFontCacheFontSize(), Monospace, StrContainsIgnoreCase(), TrueType, and TryLoadFontFromFile().

◆ LoadWin32Font()

std::unique_ptr< FontCache > Win32FontCacheFactory::LoadWin32Font ( FontSize fs,
const LOGFONT & logfont,
uint size,
std::string_view font_name )
inlinestaticprivate

Definition at line 328 of file font_win32.cpp.

◆ TryLoadFontFromFile()

bool Win32FontCacheFactory::TryLoadFontFromFile ( const std::string & font_name,
LOGFONT & logfont )
inlinestaticprivate

Try to load a font by filename.

Parameters
font_nameFilename to load.
[out]logfontOS handle to update if font is found.
Returns
true iff the font filename was found.

Definition at line 346 of file font_win32.cpp.

References Base, convert_to_fs(), FileExists(), FioFindFullPath(), LibraryLoader::GetFunction(), lengthof, and StrContainsIgnoreCase().

Referenced by LoadFont().

Field Documentation

◆ instance

Win32FontCacheFactory Win32FontCacheFactory::instance
staticprivate

Definition at line 396 of file font_win32.cpp.


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