ReactOS 0.4.15-dev-8231-g29a56f3
font.h
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Console Server DLL
3 * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4 * PURPOSE: Console GDI Fonts Management.
5 * COPYRIGHT: Copyright 2017-2022 Hermès Bélusca-Maïto
6 * Copyright 2017 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
7 */
8
9#pragma once
10
11/* DEFINES ********************************************************************/
12
13#define INVALID_CP ((UINT)-1)
14
15#ifndef CP_UTF8
16#define CP_UTF8 65001
17#endif
18
19#define CP_USA 437 // United States (OEM)
20
21#include <cjkcode.h>
22
23#define IsBoldFont(Weight) \
24 ((Weight) >= FW_SEMIBOLD) /* Sometimes, just > FW_MEDIUM */
25
26/*
27 * @struct TrueType font list, cached from
28 * HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Console\TrueTypeFont
29 *
30 * See the definition of struct _TT_FONT_LIST
31 * in https://github.com/microsoft/terminal/blob/main/dep/Console/winconp.h
32 */
33#define BOLD_MARK L'*'
34
35typedef struct _TT_FONT_ENTRY
36{
43
44
45/* FUNCTIONS ******************************************************************/
46
47BYTE
49 _In_ UINT CodePage);
50
51// FIXME: Will be redefined once we support a font cache.
52typedef struct _FONT_DATA
53{
60
66 PWSTR FaceName,
67 _In_ ULONG FontWeight,
69 _In_ UINT CodePage,
70 _In_ BOOL UseDefaultFallback,
71 _Out_ PFONT_DATA FontData);
72
78
82
83_Success_(return)
84BOOL
85GetFontCellSize(
90
91BOOL
93 _In_ PLOGFONTW lplf,
95 _In_ DWORD FontType,
96 _In_ UINT CodePage);
97
98BOOL
100 // _In_reads_or_z_(LF_FACESIZE)
101 _In_ PCWSTR FaceName,
102 _In_ UINT CodePage);
103
104
105VOID
107
108VOID
110
111VOID
113
117 PCWSTR FaceName,
118 _In_ UINT CodePage);
119
131#define IsAdditionalTTFont(FaceName) \
132 (FindCachedTTFont((FaceName), INVALID_CP) != NULL)
133
134#define IsAdditionalTTFontCP(FaceName, CodePage) \
135 (FindCachedTTFont((FaceName), (CodePage)) != NULL)
136
137/* EOF */
static HDC hDC
Definition: 3dtext.c:33
#define LF_FACESIZE
Definition: dimm.idl:39
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
static HDC
Definition: imagelist.c:92
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
#define _Success_(expr)
Definition: ms_sal.h:259
#define _Inout_
Definition: ms_sal.h:378
#define _In_reads_or_z_opt_(size)
Definition: ms_sal.h:326
#define _Inout_updates_z_(size)
Definition: ms_sal.h:389
#define _Out_
Definition: ms_sal.h:345
#define _In_
Definition: ms_sal.h:308
#define _In_opt_
Definition: ms_sal.h:309
unsigned int * PUINT
Definition: ndis.h:50
unsigned int UINT
Definition: ndis.h:50
long LONG
Definition: pedump.c:60
Definition: bl.h:1338
BYTE CharSet
Definition: font.h:58
_Inout_updates_z_(LF_FACESIZE) PWSTR FaceName
COORD Size
Definition: font.h:57
ULONG Family
Definition: font.h:56
ULONG Weight
Definition: font.h:55
Definition: ntbasedef.h:628
Definition: font.h:36
WCHAR FaceName[LF_FACESIZE]
Definition: font.h:40
BOOL DisableBold
Definition: font.h:39
UINT CodePage
Definition: font.h:38
SINGLE_LIST_ENTRY Entry
Definition: font.h:37
WCHAR FaceNameAlt[LF_FACESIZE]
Definition: font.h:41
static CONSOLE_SCREEN_BUFFER_INFO ConsoleInfo
Definition: video.c:47
uint16_t * PWSTR
Definition: typedefs.h:56
const uint16_t * PCWSTR
Definition: typedefs.h:57
uint32_t ULONG
Definition: typedefs.h:59
_In_ HFONT hFont
Definition: font.h:87
PTT_FONT_ENTRY FindCachedTTFont(_In_reads_or_z_opt_(LF_FACESIZE) PCWSTR FaceName, _In_ UINT CodePage)
Searches for a font in the console TrueType font cache, with the specified code page.
Definition: font.c:1183
HFONT CreateConsoleFont(_Inout_ PCONSOLE_STATE_INFO ConsoleInfo)
A wrapper for CreateConsoleFontEx().
Definition: font.c:653
VOID InitTTFontCache(VOID)
Initializes the console TrueType font cache.
Definition: font.c:1013
BOOL IsValidConsoleFont2(_In_ PLOGFONTW lplf, _In_ PNEWTEXTMETRICW lpntm, _In_ DWORD FontType, _In_ UINT CodePage)
Validates whether a given font can be supported in the console, under the specified code page.
Definition: font.c:782
struct _FONT_DATA FONT_DATA
struct _FONT_DATA * PFONT_DATA
struct _TT_FONT_ENTRY * PTT_FONT_ENTRY
_In_ HFONT _Out_ PUINT _Out_ PUINT Width
Definition: font.h:89
_In_ HFONT _Out_ PUINT Height
Definition: font.h:88
struct _TT_FONT_ENTRY TT_FONT_ENTRY
HFONT CreateConsoleFontEx(_In_ LONG Height, _In_opt_ LONG Width, _Inout_updates_z_(LF_FACESIZE) PWSTR FaceName, _In_ ULONG FontWeight, _In_ ULONG FontFamily, _In_ UINT CodePage, _In_ BOOL UseDefaultFallback, _Out_ PFONT_DATA FontData)
Validates and creates a suitable console font based on the font characteristics given in input.
Definition: font.c:505
BOOL IsValidConsoleFont(_In_ PCWSTR FaceName, _In_ UINT CodePage)
Validates whether a given font can be supported in the console, under the specified code page.
Definition: font.c:974
HFONT CreateConsoleFont2(_In_ LONG Height, _In_opt_ LONG Width, _Inout_ PCONSOLE_STATE_INFO ConsoleInfo)
A wrapper for CreateConsoleFontEx().
Definition: font.c:609
BYTE CodePageToCharSet(_In_ UINT CodePage)
Retrieves the character set associated with a given code page.
Definition: font.c:51
VOID ClearTTFontCache(VOID)
Clears the console TrueType font cache.
Definition: font.c:1131
VOID RefreshTTFontCache(VOID)
Refreshes the console TrueType font cache, by clearing and re-initializing it.
Definition: font.c:1153
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned char BYTE
Definition: xxhash.c:193