OpenTTD Source  20241121-master-g67a0fccfad
font_win32.cpp File Reference

Functions related to font handling on Win32. More...

#include "../../stdafx.h"
#include "../../debug.h"
#include "../../blitter/factory.hpp"
#include "../../core/math_func.hpp"
#include "../../core/mem_func.hpp"
#include "../../error_func.h"
#include "../../fileio_func.h"
#include "../../fontcache.h"
#include "../../fontcache/truetypefontcache.h"
#include "../../fontdetection.h"
#include "../../library_loader.h"
#include "../../string_func.h"
#include "../../strings_func.h"
#include "../../zoom_func.h"
#include "font_win32.h"
#include "../../table/control_codes.h"
#include <windows.h>
#include <shlobj.h>
#include "os/windows/win32.h"
#include "safeguards.h"

Go to the source code of this file.

Data Structures

struct  EFCParam
 

Functions

static int CALLBACK EnumFontCallback (const ENUMLOGFONTEX *logfont, const NEWTEXTMETRICEX *metric, DWORD type, LPARAM lParam)
 
bool SetFallbackFont (FontCacheSettings *settings, const std::string &, int winlangid, MissingGlyphSearcher *callback)
 We would like to have a fallback font as the current one doesn't contain all characters we need. More...
 
static bool TryLoadFontFromFile (const std::string &font_name, LOGFONT &logfont)
 
static void LoadWin32Font (FontSize fs, const LOGFONT &logfont, uint size, const char *font_name)
 
void LoadWin32Font (FontSize fs)
 Loads the GDI font. More...
 

Detailed Description

Functions related to font handling on Win32.

Definition in file font_win32.cpp.

Function Documentation

◆ LoadWin32Font()

void LoadWin32Font ( FontSize  fs)

Loads the GDI font.

If a GDI font description is present, e.g. from the automatic font fallback search, use it. Otherwise, try to resolve it by font name.

Parameters
fsThe font size to load.

Definition at line 352 of file font_win32.cpp.

References FS_MONO, GetFontCacheFontName(), GetFontCacheSubSetting(), MemSetT(), and settings.

◆ SetFallbackFont()

bool SetFallbackFont ( struct FontCacheSettings settings,
const std::string &  language_isocode,
int  winlangid,
class MissingGlyphSearcher callback 
)

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.
winlangidthe language ID windows style.
callbackThe function to call to check for missing glyphs.
Returns
true if a font has been set, false otherwise.

Definition at line 78 of file font_win32.cpp.

References Debug, lengthof, and settings.