OpenTTD Source 20241224-master-gee860a5c8e
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.
 
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.
 

Detailed Description

Functions related to font handling on Win32.

Definition in file font_win32.cpp.

Function Documentation

◆ EnumFontCallback()

static int CALLBACK EnumFontCallback ( const ENUMLOGFONTEX *  logfont,
const NEWTEXTMETRICEX *  metric,
DWORD  type,
LPARAM  lParam 
)
static

Definition at line 53 of file font_win32.cpp.

◆ LoadWin32Font() [1/2]

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 convert_to_fs(), FS_MONO, GetFontCacheFontName(), GetFontCacheFontSize(), GetFontCacheSubSetting(), MemSetT(), and settings.

Referenced by InitFontCache().

◆ LoadWin32Font() [2/2]

static void LoadWin32Font ( FontSize  fs,
const LOGFONT &  logfont,
uint  size,
const char *  font_name 
)
static

Definition at line 335 of file font_win32.cpp.

◆ 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, MissingGlyphSearcher::FindMissingGlyphs(), lengthof, MissingGlyphSearcher::Monospace(), MissingGlyphSearcher::SetFontNames(), and settings.

Referenced by CheckForMissingGlyphs().

◆ TryLoadFontFromFile()

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

Definition at line 286 of file font_win32.cpp.