ReactOS 0.4.15-dev-7788-g1ad9096
font.h File Reference
#include <cjkcode.h>
Include dependency graph for font.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _TT_FONT_ENTRY
 
struct  _FONT_DATA
 

Macros

#define INVALID_CP   ((UINT)-1)
 
#define CP_UTF8   65001
 
#define CP_USA   437
 
#define IsBoldFont(Weight)    ((Weight) >= FW_SEMIBOLD) /* Sometimes, just > FW_MEDIUM */
 
#define BOLD_MARK   L'*'
 
#define IsAdditionalTTFont(FaceName)    (FindCachedTTFont((FaceName), INVALID_CP) != NULL)
 Verifies whether the given font is an additional console TrueType font. Wrapper macros around FindCachedTTFont().
 
#define IsAdditionalTTFontCP(FaceName, CodePage)    (FindCachedTTFont((FaceName), (CodePage)) != NULL)
 

Typedefs

typedef struct _TT_FONT_ENTRY TT_FONT_ENTRY
 
typedef struct _TT_FONT_ENTRYPTT_FONT_ENTRY
 
typedef struct _FONT_DATA FONT_DATA
 
typedef struct _FONT_DATAPFONT_DATA
 

Functions

BYTE CodePageToCharSet (_In_ UINT CodePage)
 Retrieves the character set associated with a given code page.
 
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.
 
HFONT CreateConsoleFont2 (_In_ LONG Height, _In_opt_ LONG Width, _Inout_ PCONSOLE_STATE_INFO ConsoleInfo)
 A wrapper for CreateConsoleFontEx().
 
HFONT CreateConsoleFont (_Inout_ PCONSOLE_STATE_INFO ConsoleInfo)
 A wrapper for CreateConsoleFontEx().
 
 _Success_ (return) BOOL GetFontCellSize(_In_opt_ HDC hDC
 
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.
 
BOOL IsValidConsoleFont (_In_ PCWSTR FaceName, _In_ UINT CodePage)
 Validates whether a given font can be supported in the console, under the specified code page.
 
VOID InitTTFontCache (VOID)
 Initializes the console TrueType font cache.
 
VOID ClearTTFontCache (VOID)
 Clears the console TrueType font cache.
 
VOID RefreshTTFontCache (VOID)
 Refreshes the console TrueType font cache, by clearing and re-initializing it.
 
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.
 

Variables

_In_ HFONT hFont
 
_In_ HFONT _Out_ PUINT Height
 
_In_ HFONT _Out_ PUINT _Out_ PUINT Width
 

Macro Definition Documentation

◆ BOLD_MARK

#define BOLD_MARK   L'*'

Definition at line 33 of file font.h.

◆ CP_USA

#define CP_USA   437

Definition at line 19 of file font.h.

◆ CP_UTF8

#define CP_UTF8   65001

Definition at line 16 of file font.h.

◆ INVALID_CP

#define INVALID_CP   ((UINT)-1)

Definition at line 13 of file font.h.

◆ IsAdditionalTTFont

#define IsAdditionalTTFont (   FaceName)     (FindCachedTTFont((FaceName), INVALID_CP) != NULL)

Verifies whether the given font is an additional console TrueType font. Wrapper macros around FindCachedTTFont().

Remarks
These macros are equivalents of the functions IsAvailableTTFont() and IsAvailableTTFontCP() in https://github.com/microsoft/terminal/blob/main/src/propsheet/dbcs.cpp

Definition at line 131 of file font.h.

◆ IsAdditionalTTFontCP

#define IsAdditionalTTFontCP (   FaceName,
  CodePage 
)     (FindCachedTTFont((FaceName), (CodePage)) != NULL)

Definition at line 134 of file font.h.

◆ IsBoldFont

#define IsBoldFont (   Weight)     ((Weight) >= FW_SEMIBOLD) /* Sometimes, just > FW_MEDIUM */

Definition at line 23 of file font.h.

Typedef Documentation

◆ FONT_DATA

◆ PFONT_DATA

◆ PTT_FONT_ENTRY

◆ TT_FONT_ENTRY

Function Documentation

◆ _Success_()

_Success_ ( return  )

◆ ClearTTFontCache()

VOID ClearTTFontCache ( VOID  )

Clears the console TrueType font cache.

Returns
None.

Definition at line 1131 of file font.c.

1132{
1134 PTT_FONT_ENTRY FontEntry;
1135
1136 while (TTFontCache.Next != NULL)
1137 {
1140 RtlFreeHeap(RtlGetProcessHeap(), 0, FontEntry);
1141 }
1143}
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:608
#define NULL
Definition: types.h:112
base of all file and directory entries
Definition: entries.h:83
Definition: ntbasedef.h:628
struct _SINGLE_LIST_ENTRY * Next
Definition: ntbasedef.h:629
Definition: font.h:36
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
SINGLE_LIST_ENTRY TTFontCache
Definition: font.c:32
FORCEINLINE PSINGLE_LIST_ENTRY PopEntryList(_Inout_ PSINGLE_LIST_ENTRY ListHead)
Definition: rtlfuncs.h:240

Referenced by InitApplet(), and RefreshTTFontCache().

◆ CodePageToCharSet()

BYTE CodePageToCharSet ( _In_ UINT  CodePage)

Retrieves the character set associated with a given code page.

Parameters
[in]CodePageThe code page to convert.
Returns
The character set corresponding to the code page, or DEFAULT_CHARSET.

Definition at line 51 of file font.c.

53{
54 CHARSETINFO CharInfo;
55 if (TranslateCharsetInfo(UlongToPtr(CodePage), &CharInfo, TCI_SRCCODEPAGE))
56 return (BYTE)CharInfo.ciCharset;
57 else
58 return DEFAULT_CHARSET;
59}
#define UlongToPtr(u)
Definition: config.h:106
UINT ciCharset
Definition: wingdi.h:1546
#define DEFAULT_CHARSET
Definition: wingdi.h:384
BOOL WINAPI TranslateCharsetInfo(_Inout_ PDWORD, _Out_ LPCHARSETINFO, _In_ DWORD)
#define TCI_SRCCODEPAGE
Definition: wingdi.h:962
unsigned char BYTE
Definition: xxhash.c:193

Referenced by CON_API(), CreateConsoleFontWorker(), FindSuitableFont(), and IsValidConsoleFont().

◆ CreateConsoleFont()

HFONT CreateConsoleFont ( _Inout_ PCONSOLE_STATE_INFO  ConsoleInfo)

A wrapper for CreateConsoleFontEx().

Parameters
[in,out]ConsoleInfoA pointer to console settings information, containing in particular (in input) the face name and characteristics of the font to create with the current console code page. In output, the font information gets updated. Note that a default fallback font is always being used in case neither the specified font nor any substitute font could be found and created for the specified code page.
Returns
A GDI handle to the created font, or NULL in case of failure.
See also
CreateConsoleFontEx(), CreateConsoleFont2()

Definition at line 653 of file font.c.

655{
656 /*
657 * Format:
658 * Width = FontSize.X = LOWORD(FontSize);
659 * Height = FontSize.Y = HIWORD(FontSize);
660 */
661 /* NOTE: FontSize is always in cell height/width units (pixels) */
662 return CreateConsoleFont2((LONG)(ULONG)ConsoleInfo->FontSize.Y,
663 (LONG)(ULONG)ConsoleInfo->FontSize.X,
665}
long LONG
Definition: pedump.c:60
static CONSOLE_SCREEN_BUFFER_INFO ConsoleInfo
Definition: video.c:47
uint32_t ULONG
Definition: typedefs.h:59
HFONT CreateConsoleFont2(_In_ LONG Height, _In_opt_ LONG Width, _Inout_ PCONSOLE_STATE_INFO ConsoleInfo)
A wrapper for CreateConsoleFontEx().
Definition: font.c:609

Referenced by RefreshFontPreview().

◆ CreateConsoleFont2()

HFONT CreateConsoleFont2 ( _In_ LONG  Height,
_In_opt_ LONG  Width,
_Inout_ PCONSOLE_STATE_INFO  ConsoleInfo 
)

A wrapper for CreateConsoleFontEx().

Parameters
[in]HeightThe font height in cell units (pixels).
[in,opt]Width The font width in cell units (pixels).
[in,out]ConsoleInfoA pointer to console settings information, containing in particular (in input) the face name and characteristics of the font to create with the current console code page. In output, the font information gets updated. Note that a default fallback font is always being used in case neither the specified font nor any substitute font could be found and created for the specified code page.
Returns
A GDI handle to the created font, or NULL in case of failure.
See also
CreateConsoleFontEx(), CreateConsoleFont()

Definition at line 609 of file font.c.

613{
614 FONT_DATA FontData;
615 HFONT hFont;
616
618 Width,
619 ConsoleInfo->FaceName,
620 ConsoleInfo->FontWeight,
621 ConsoleInfo->FontFamily,
622 ConsoleInfo->CodePage,
623 TRUE, // UseDefaultFallback
624 &FontData);
625 if (hFont)
626 {
627 ConsoleInfo->FontWeight = FontData.Weight;
628 ConsoleInfo->FontFamily = FontData.Family;
629 }
630
631 return hFont;
632}
HFONT hFont
Definition: main.c:53
#define TRUE
Definition: types.h:120
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
ULONG Family
Definition: font.h:56
ULONG Weight
Definition: font.h:55
_In_ HFONT _Out_ PUINT _Out_ PUINT Width
Definition: font.h:89
_In_ HFONT _Out_ PUINT Height
Definition: font.h:88
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

Referenced by CreateConsoleFont(), and FontSizeChange().

◆ CreateConsoleFontEx()

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.

Parameters
[in]HeightThe font height in cell units (pixels).
[in,opt]Width The font width in cell units (pixels).
[in,out]FaceNameA pointer to a maximally LF_FACESIZE-sized buffer. In input: The buffer contains the face name of the font to try to create. In output: The buffer receives the face name of the font that has been created, in case of success. It may, or may not be, identical to the face name provided in input, in case a substitute font has been chosen.
[in]FontWeightThe font weight.
[in]FontFamilyThe font family.
[in]CodePageThe code page the font has to support.
[in]UseDefaultFallbackWhether (TRUE) or not (FALSE) to use a default fallback font in case neither the specified font nor any substitute font could be found and created for the specified code page.
[out]FontDataThe face name and characteristics of the created font.
Returns
A GDI handle to the created font, or NULL in case of failure.
Remarks
Similar to FindCreateFont() https://github.com/microsoft/terminal/blob/main/src/propsheet/fontdlg.cpp#L1113 but:
  • does not support an internal font cache for now;
  • returns a font handle (and not a font index to the cache).

Definition at line 505 of file font.c.

515{
516 HFONT hFont;
517
518 FontData->FaceName = FaceName;
519 FontData->Weight = FontWeight;
520 FontData->Family = FontFamily;
521 /* NOTE: FontSize is always in cell height/width units (pixels) */
522 FontData->Size.X = Width;
523 FontData->Size.Y = Height;
524 FontData->CharSet = 0; // CodePageToCharSet(CodePage);
525
526 if (/* !FaceName || */ !*FaceName || wcscmp(FaceName, DEFAULT_TT_FONT_FACENAME) == 0)
527 {
528 /* We do not have an actual font face name yet and should find one.
529 * Call FindSuitableFont() to determine the default font to use. */
530 }
531 else
532 {
533 hFont = CreateConsoleFontWorker(FontData, CodePage);
534 if (hFont)
535 return hFont;
536
537 DBGFNT1("CreateConsoleFont('%S') failed - Try to find a suitable font...\n",
538 FaceName);
539 }
540
541 /*
542 * We could not create a font with the default settings.
543 * Try to find a suitable font and retry.
544 */
545 if (!FindSuitableFont(FontData, CodePage))
546 {
547 /* We could not find any suitable font, fall back
548 * to some default one if required to do so. */
549 DBGFNT1("FindSuitableFont could not find anything - %s\n",
550 UseDefaultFallback ? "Falling back to 'Terminal'"
551 : "Bailing out");
552
553 /* No fallback: no font! */
554 if (!UseDefaultFallback)
555 return NULL;
556
557 //
558 // FIXME: See also !*FaceName case in FindSuitableFont().
559 //
560 /* Use "Terminal" as the fallback */
562#if 0
563 // FIXME: CJK font choose workaround: Don't choose Asian
564 // charset font if there is no preferred font for CJK.
565 if (IsCJKCodePage(CodePage))
566 FontData->CharSet = ANSI_CHARSET;
567#endif
568 FontData->Family &= ~TMPF_TRUETYPE;
569 }
570 else
571 {
572 DBGFNT1("FindSuitableFont found: '%S', size (%d x %d)\n",
573 FaceName, FontData->Size.X, FontData->Size.Y);
574 }
575
576 /* Retry creating the font */
577 hFont = CreateConsoleFontWorker(FontData, CodePage);
578 if (!hFont)
579 DBGFNT1("CreateConsoleFont('%S') failed\n", FaceName);
580
581 return hFont;
582}
#define IsCJKCodePage(CodePage)
Definition: cjkcode.h:27
#define LF_FACESIZE
Definition: dimm.idl:39
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
#define TERMINAL_FACENAME
Definition: font.c:27
#define DBGFNT1
Definition: font.c:22
static HFONT CreateConsoleFontWorker(_In_ PFONT_DATA FontData, _In_ UINT CodePage)
Validates and creates a suitable console font based on the font characteristics given in input.
Definition: font.c:424
#define DEFAULT_TT_FONT_FACENAME
Definition: font.c:29
static BOOL FindSuitableFont(_Inout_ PFONT_DATA FontData, _In_ UINT CodePage)
Finds a font suitable for the given code page, based on the current font and its characteristics prov...
Definition: font.c:307
#define ANSI_CHARSET
Definition: wingdi.h:383

Referenced by CreateConsoleFont2(), and InitFonts().

◆ FindCachedTTFont()

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.

Parameters
[in,opt]FaceName An optional pointer to a maximally LF_FACESIZE-sized buffer. The buffer contains the face name of the font to search for.
  • If FaceName != NULL, search for the named font that should match the provided code page (when CodePage != INVALID_CP).
  • If FaceName == NULL, search for a font with the provided code page. In this case, CodePage cannot be == INVALID_CP, otherwise the search fails.
Parameters
[in]CodePageThe code page the font has to support, or INVALID_CP when searching a font by face name only.
Returns
A pointer to the cache entry for the font, or NULL if not found.

Definition at line 1183 of file font.c.

1187{
1189 PTT_FONT_ENTRY FontEntry;
1190
1191 if (FaceName)
1192 {
1193 /* Search for the named font */
1194 for (Entry = TTFontCache.Next;
1195 Entry != NULL;
1196 Entry = Entry->Next)
1197 {
1199
1200 /* NOTE: The font face names are case-sensitive */
1201 if ((wcscmp(FontEntry->FaceName , FaceName) == 0) ||
1202 (wcscmp(FontEntry->FaceNameAlt, FaceName) == 0))
1203 {
1204 /* Return the font if we don't search by code page, or when they match */
1205 if ((CodePage == INVALID_CP) || (CodePage == FontEntry->CodePage))
1206 {
1207 return FontEntry;
1208 }
1209 }
1210 }
1211 }
1212 else if (CodePage != INVALID_CP)
1213 {
1214 /* Search for a font with the specified code page */
1215 for (Entry = TTFontCache.Next;
1216 Entry != NULL;
1217 Entry = Entry->Next)
1218 {
1220
1221 /* Return the font if the code pages match */
1222 if (CodePage == FontEntry->CodePage)
1223 return FontEntry;
1224 }
1225 }
1226
1227 return NULL;
1228}
#define INVALID_CP
Definition: stream.h:53
WCHAR FaceName[LF_FACESIZE]
Definition: font.h:40
UINT CodePage
Definition: font.h:38
WCHAR FaceNameAlt[LF_FACESIZE]
Definition: font.h:41

Referenced by FindSuitableFont().

◆ InitTTFontCache()

VOID InitTTFontCache ( VOID  )

Initializes the console TrueType font cache.

Remarks
To install additional TrueType fonts to be available for the console, add entries of type REG_SZ named "0", "00" etc... in: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Console\TrueTypeFont The names of the fonts listed there should match those in: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Fonts
Returns
None.

Definition at line 1013 of file font.c.

1014{
1015 LRESULT lResult;
1016 HKEY hKey;
1017 DWORD dwIndex, dwType;
1018 WCHAR szValueName[MAX_PATH];
1019 DWORD cchValueName;
1020 WCHAR szValue[LF_FACESIZE] = L"";
1021 DWORD cbValue;
1022 UINT CodePage;
1023 PTT_FONT_ENTRY FontEntry;
1024 PWCHAR pszNext;
1025
1026 if (TTFontCache.Next != NULL)
1027 return;
1028 // TTFontCache.Next = NULL;
1029
1030 /* Open the Console\TrueTypeFont key */
1031 // "\\Registry\\Machine\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Console\\TrueTypeFont"
1033 L"Software\\Microsoft\\Windows NT\\CurrentVersion\\Console\\TrueTypeFont",
1034 0,
1036 &hKey) != ERROR_SUCCESS)
1037 {
1038 return;
1039 }
1040
1041 /* Enumerate all the available TrueType console fonts */
1042 for (dwIndex = 0, cchValueName = ARRAYSIZE(szValueName),
1043 cbValue = sizeof(szValue);
1044 (lResult = RegEnumValueW(hKey, dwIndex,
1045 szValueName, &cchValueName,
1046 NULL, &dwType,
1047 (PBYTE)szValue, &cbValue)) != ERROR_NO_MORE_ITEMS;
1048 ++dwIndex, cchValueName = ARRAYSIZE(szValueName),
1049 cbValue = sizeof(szValue))
1050 {
1051 /* Ignore if we failed for another reason, e.g. because
1052 * the value name is too long (and thus, invalid). */
1053 if (lResult != ERROR_SUCCESS)
1054 continue;
1055
1056 /* Validate the value name (exclude the unnamed value) */
1057 if (!cchValueName || (*szValueName == UNICODE_NULL))
1058 continue;
1059 /* Too large value names have already been handled with ERROR_MORE_DATA */
1060 ASSERT((cchValueName < ARRAYSIZE(szValueName)) &&
1061 (szValueName[cchValueName] == UNICODE_NULL));
1062
1063 /* Only (multi-)string values are supported */
1064 if ((dwType != REG_SZ) && (dwType != REG_MULTI_SZ))
1065 continue;
1066
1067 /* The value name is a code page (in decimal), validate it */
1068 CodePage = wcstoul(szValueName, &pszNext, 10);
1069 if (*pszNext)
1070 continue; // Non-numerical garbage followed...
1071 // IsValidCodePage(CodePage);
1072
1073 FontEntry = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*FontEntry));
1074 if (!FontEntry)
1075 {
1076 DBGFNT1("InitTTFontCache: Failed to allocate memory, continuing...\n");
1077 continue;
1078 }
1079
1080 FontEntry->CodePage = CodePage;
1081
1082 pszNext = szValue;
1083
1084 /* Check whether bold is disabled for this font */
1085 if (*pszNext == BOLD_MARK)
1086 {
1087 FontEntry->DisableBold = TRUE;
1088 ++pszNext;
1089 }
1090 else
1091 {
1092 FontEntry->DisableBold = FALSE;
1093 }
1094
1095 /* Copy the font name */
1096 StringCchCopyNW(FontEntry->FaceName, ARRAYSIZE(FontEntry->FaceName),
1097 pszNext, wcslen(pszNext));
1098
1099 if (dwType == REG_MULTI_SZ)
1100 {
1101 /* There may be an alternate face name as the second string */
1102 pszNext += wcslen(pszNext) + 1;
1103
1104 /* Check whether bold is disabled for this font */
1105 if (*pszNext == BOLD_MARK)
1106 {
1107 FontEntry->DisableBold = TRUE;
1108 ++pszNext;
1109 }
1110 // else, keep the original setting.
1111
1112 /* Copy the alternate font name */
1113 StringCchCopyNW(FontEntry->FaceNameAlt, ARRAYSIZE(FontEntry->FaceNameAlt),
1114 pszNext, wcslen(pszNext));
1115 }
1116
1117 PushEntryList(&TTFontCache, &FontEntry->Entry);
1118 }
1119
1120 /* Close the key and quit */
1122}
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:590
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
#define FALSE
Definition: types.h:117
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3362
LONG WINAPI RegEnumValueW(_In_ HKEY hKey, _In_ DWORD index, _Out_ LPWSTR value, _Inout_ PDWORD val_count, _Reserved_ PDWORD reserved, _Out_opt_ PDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ PDWORD count)
Definition: reg.c:2859
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:105
#define MAX_PATH
Definition: compat.h:34
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
_Check_return_ unsigned long __cdecl wcstoul(_In_z_ const wchar_t *_Str, _Out_opt_ _Deref_post_z_ wchar_t **_EndPtr, _In_ int _Radix)
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define REG_SZ
Definition: layer.c:22
#define ASSERT(a)
Definition: mode.c:44
unsigned int UINT
Definition: ndis.h:50
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define REG_MULTI_SZ
Definition: nt_native.h:1501
#define UNICODE_NULL
#define L(x)
Definition: ntvdm.h:50
BYTE * PBYTE
Definition: pedump.c:66
STRSAFEAPI StringCchCopyNW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc, size_t cchToCopy)
Definition: strsafe.h:236
BOOL DisableBold
Definition: font.h:39
SINGLE_LIST_ENTRY Entry
Definition: font.h:37
uint16_t * PWCHAR
Definition: typedefs.h:56
#define BOLD_MARK
Definition: font.h:33
LONG_PTR LRESULT
Definition: windef.h:209
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
FORCEINLINE VOID PushEntryList(_Inout_ PSINGLE_LIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PSINGLE_LIST_ENTRY Entry)
Definition: rtlfuncs.h:253
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by GuiInit(), InitApplet(), and RefreshTTFontCache().

◆ IsValidConsoleFont()

BOOL IsValidConsoleFont ( _In_ PCWSTR  FaceName,
_In_ UINT  CodePage 
)

Validates whether a given font can be supported in the console, under the specified code page.

Parameters
[in]FaceNameThe face name of the font to validate.
[in]CodePageThe code page the font has to support.
Returns
TRUE if the font is valid and supported in the console, FALSE if not.
See also
IsValidConsoleFont2()

Definition at line 974 of file font.c.

978{
980 HDC hDC;
981 LOGFONTW lf;
982
983 Param.IsValidFont = FALSE;
984 Param.CodePage = CodePage;
985
986 RtlZeroMemory(&lf, sizeof(lf));
987 lf.lfCharSet = CodePageToCharSet(CodePage);
988 // lf.lfPitchAndFamily = FIXED_PITCH | FF_MODERN;
990
991 hDC = GetDC(NULL);
994
995 return Param.IsValidFont;
996}
static HDC hDC
Definition: 3dtext.c:33
static HDC
Definition: imagelist.c:92
WCHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:72
BYTE lfCharSet
Definition: dimm.idl:67
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
static BOOL CALLBACK IsValidConsoleFontProc(_In_ PLOGFONTW lplf, _In_ PNEWTEXTMETRICW lpntm, _In_ DWORD FontType, _In_ LPARAM lParam)
EnumFontFamiliesEx() callback helper for IsValidConsoleFont().
Definition: font.c:943
BYTE CodePageToCharSet(_In_ UINT CodePage)
Retrieves the character set associated with a given code page.
Definition: font.c:51
LONG_PTR LPARAM
Definition: windef.h:208
int WINAPI EnumFontFamiliesExW(_In_ HDC, _In_ PLOGFONTW, _In_ FONTENUMPROCW, _In_ LPARAM, _In_ DWORD)
FARPROC FONTENUMPROCW
Definition: wingdi.h:2897
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
HDC WINAPI GetDC(_In_opt_ HWND)

Referenced by CreateConsoleFontWorker().

◆ IsValidConsoleFont2()

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.

Parameters
[in]lplf
[in]lpntm
[in]FontTypeThe GDI font characteristics of the font to validate.
[in]CodePageThe code page the font has to support.
Returns
TRUE if the font is valid and supported in the console, FALSE if not.
Remarks
Equivalent of the font validation tests in FontEnumForV2Console() (or the more restrictive ones in FontEnum()) https://github.com/microsoft/terminal/blob/main/src/propsheet/misc.cpp#L465 https://github.com/microsoft/terminal/blob/main/src/propsheet/misc.cpp#L607
See also
IsValidConsoleFont()

Definition at line 782 of file font.c.

787{
788 LPCWSTR FaceName = lplf->lfFaceName;
789
790 /*
791 * According to: https://web.archive.org/web/20140901124501/http://support.microsoft.com/kb/247815
792 * "Necessary criteria for fonts to be available in a command window",
793 * the criteria for console-eligible fonts are as follows:
794 * - The font must be a fixed-pitch font.
795 * - The font cannot be an italic font.
796 * - The font cannot have a negative A or C space.
797 * - If it is a TrueType font, it must be FF_MODERN.
798 * - If it is not a TrueType font, it must be OEM_CHARSET.
799 *
800 * Non documented: vertical fonts are forbidden (their name start with a '@').
801 *
802 * Additional criteria for Asian installations:
803 * - If it is not a TrueType font, the face name must be "Terminal".
804 * - If it is an Asian TrueType font, it must also be an Asian character set.
805 *
806 * See also Raymond Chen's blog: https://devblogs.microsoft.com/oldnewthing/?p=26843
807 * and MIT-licensed Microsoft Terminal source code: https://github.com/microsoft/terminal/blob/main/src/propsheet/misc.cpp
808 * for other details.
809 *
810 * To install additional TrueType fonts to be available for the console,
811 * add entries of type REG_SZ named "0", "00" etc... in:
812 * HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Console\TrueTypeFont
813 * The names of the fonts listed there should match those in:
814 * HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Fonts
815 */
816
817 /*
818 * In ReactOS we relax some of the criteria:
819 * - We allow fixed-pitch FF_MODERN (Monospace) TrueType fonts
820 * that can be italic or have negative A or C space.
821 * - If it is not a TrueType font, it can be from another character set
822 * than OEM_CHARSET. When an Asian codepage is active however, we require
823 * that this non-TrueType font has an Asian character set.
824 */
825
826 /* Reject variable-width fonts ... */
827 if ( ( ((lplf->lfPitchAndFamily & 0x03) != FIXED_PITCH)
828#if 0 /* Reject italic and TrueType fonts with negative A or C space ... */
829 || (lplf->lfItalic)
830 || !(lpntm->ntmFlags & NTM_NONNEGATIVE_AC)
831#endif
832 ) &&
833 /* ... if they are not in the list of additional TrueType fonts to include */
834 !IsAdditionalTTFont(FaceName) )
835 {
836 DBGFNT("Font '%S' rejected because it%s (lfPitchAndFamily = %d)\n",
837 FaceName,
838 !(lplf->lfPitchAndFamily & FIXED_PITCH) ? "'s not FIXED_PITCH"
839 : (!(lpntm->ntmFlags & NTM_NONNEGATIVE_AC) ? " has negative A or C space"
840 : " is broken"),
841 lplf->lfPitchAndFamily);
842 return FALSE;
843 }
844
845 /* Reject TrueType fonts that are not FF_MODERN */
846 if ((FontType == TRUETYPE_FONTTYPE) && ((lplf->lfPitchAndFamily & 0xF0) != FF_MODERN))
847 {
848 DBGFNT("TrueType font '%S' rejected because it's not FF_MODERN (lfPitchAndFamily = %d)\n",
849 FaceName, lplf->lfPitchAndFamily);
850 return FALSE;
851 }
852
853 /* Reject vertical fonts (tategaki) */
854 if (FaceName[0] == L'@')
855 {
856 DBGFNT("Font '%S' rejected because it's vertical\n", FaceName);
857 return FALSE;
858 }
859
860 /* Is the current code page Chinese, Japanese or Korean? */
861 if (IsCJKCodePage(CodePage))
862 {
863 /* It's CJK */
864
865 if (FontType == TRUETYPE_FONTTYPE)
866 {
867 /*
868 * Here we are inclusive and check for any CJK character set,
869 * instead of looking just at the current one via CodePageToCharSet().
870 */
871 if (!IsCJKCharSet(lplf->lfCharSet))
872 {
873 DBGFNT("TrueType font '%S' rejected because it's not Asian charset (lfCharSet = %d)\n",
874 FaceName, lplf->lfCharSet);
875 return FALSE;
876 }
877
878 /*
879 * If this is a cached TrueType font that is used only for certain
880 * code pages, verify that the charset it claims is the correct one.
881 *
882 * Since there may be multiple entries for a cached TrueType font,
883 * a general one (code page == 0) and one or more for explicit
884 * code pages, we need to perform two search queries instead of
885 * just one and retrieving the code page for this entry.
886 */
887 if (IsAdditionalTTFont(FaceName) && !IsAdditionalTTFontCP(FaceName, 0) &&
888 !IsCJKCharSet(lplf->lfCharSet))
889 {
890 DBGFNT("Cached TrueType font '%S' rejected because it claims a code page that is not Asian charset (lfCharSet = %d)\n",
891 FaceName, lplf->lfCharSet);
892 return FALSE;
893 }
894 }
895 else
896 {
897 /* Reject non-TrueType fonts that do not have an Asian character set */
898 if (!IsCJKCharSet(lplf->lfCharSet) && (lplf->lfCharSet != OEM_CHARSET))
899 {
900 DBGFNT("Non-TrueType font '%S' rejected because it's not Asian charset or OEM_CHARSET (lfCharSet = %d)\n",
901 FaceName, lplf->lfCharSet);
902 return FALSE;
903 }
904
905 /* Reject non-TrueType fonts that are not Terminal */
906 if (wcscmp(FaceName, TERMINAL_FACENAME) != 0)
907 {
908 DBGFNT("Non-TrueType font '%S' rejected because it's not 'Terminal'\n", FaceName);
909 return FALSE;
910 }
911 }
912 }
913 else
914 {
915 /* Not CJK */
916
917 /* Reject non-TrueType fonts that are not OEM or similar */
918 if ((FontType != TRUETYPE_FONTTYPE) &&
919 (lplf->lfCharSet != ANSI_CHARSET) &&
920 (lplf->lfCharSet != DEFAULT_CHARSET) &&
921 (lplf->lfCharSet != OEM_CHARSET))
922 {
923 DBGFNT("Non-TrueType font '%S' rejected because it's not ANSI_CHARSET or DEFAULT_CHARSET or OEM_CHARSET (lfCharSet = %d)\n",
924 FaceName, lplf->lfCharSet);
925 return FALSE;
926 }
927 }
928
929 /* All good */
930 return TRUE;
931}
#define IsCJKCharSet(CharSet)
Definition: cjkcode.h:44
#define IsAdditionalTTFontCP(FaceName, CodePage)
Definition: font.h:134
#define IsAdditionalTTFont(FaceName)
Verifies whether the given font is an additional console TrueType font. Wrapper macros around FindCac...
Definition: font.h:131
#define DBGFNT
Definition: font.c:21
#define FIXED_PITCH
Definition: wingdi.h:444
#define FF_MODERN
Definition: wingdi.h:449
#define TRUETYPE_FONTTYPE
Definition: wingdi.h:1109
#define OEM_CHARSET
Definition: wingdi.h:400
#define NTM_NONNEGATIVE_AC
Definition: wingdi.h:25
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by EnumFaceNamesProc(), FindSuitableFontProc(), and IsValidConsoleFontProc().

◆ RefreshTTFontCache()

VOID RefreshTTFontCache ( VOID  )

Refreshes the console TrueType font cache, by clearing and re-initializing it.

Returns
None.

Definition at line 1153 of file font.c.

1154{
1157}
VOID InitTTFontCache(VOID)
Initializes the console TrueType font cache.
Definition: font.c:1013
VOID ClearTTFontCache(VOID)
Clears the console TrueType font cache.
Definition: font.c:1131

Referenced by GuiApplyUserSettings().

Variable Documentation

◆ Height

Definition at line 88 of file font.h.

Referenced by _Success_(), BaseControlVideoImpl_SetDestinationPosition(), BaseControlVideoImpl_SetSourcePosition(), BaseControlWindowImpl_put_Height(), BaseControlWindowImpl_SetWindowPosition(), BaseWindowImpl_OnSize(), BasicVideo_SetDestinationPosition(), BasicVideo_SetSourcePosition(), BitBlt(), BlDisplayValidOemBitmap(), cdtInit(), ChangeView(), co_IntShowDesktop(), ConioCopyRegion(), ConsolepClearBuffer(), ConvertBmpToGopBlt(), ConWndProc(), CreateBitmap(), CreateCompatibleBitmap(), CreateConsoleFont2(), CreateConsoleFontEx(), CreateD3D9MipMap(), CreateDIBitmap(), CreateDiscardableBitmap(), CreatePopupWindow(), DECLARE_INTERFACE_(), DIB_1BPP_BitBltSrcCopy_From1BPP(), DisplayCharacter(), draw_diag_edge(), DrawBox(), DrawClassicFrame(), DrawPartitionList(), FromMouseCoordinates(), GdipAddPathRectangles(), GdipAddPathRectanglesI(), GdipDrawRectanglesI(), GdipFillRectanglesI(), CAppScrnshotPreview::GetRequestedWidth(), GuiGetLargestConsoleWindowSize(), HistoryDisplayCurrentHistory(), IDirect3DDevice9Base_CreateTexture(), InbvBufferToScreenBlt(), InbvScreenToBufferBlt(), InitGL(), InitImageList(), InitMetrics(), IntCreateCompatibleBitmap(), IntDrawArc(), IntDrawDiagEdge(), IntDrawEllipse(), IntEngFillBox(), InternetExplorer_put_Height(), IntFillArc(), IntFillEllipse(), IntFillRect(), IntGdiCreateMaskFromRLE(), IntPatBlt(), LISTVIEW_Size(), LlbFwVideoGetDisplaySize(), CGridView::MapWndProc(), MediaDet_GetBitmapBits(), MediaDet_WriteBitmapBits(), MENU_DrawMenuItem(), metafile_deserialize_image(), METAFILE_FillRectangles(), MiniTuiDrawProgressBarCenter(), MyMakeSquareRect(), NC_DrawFrame(), NtGdiBitBlt(), NtGdiCreateCompatibleBitmap(), NtGdiRoundRect(), NtGdiSetBitmapDimension(), NtGdiSetDIBitsToDeviceInternal(), CDeviceManager::OnCommand(), Pc98VideoGetDisplaySize(), PcVideoGetDisplaySize(), PopupError(), PrintDiskData(), PrintEmptyLine(), PrintPartitionData(), ProcessDisplayRegistry(), CAppInfoDisplay::ResizeChildren(), ResizeControls(), ResizeConWnd(), ReSizeGLScene(), ResizeTextConsole(), RleBitBlt(), set_client_height(), SetDIBitsToDevice(), ShellUIHelper2_AddDesktopComponent(), test_D3DXCreateRenderToSurface(), test_excludeinfinite(), test_Get_Release_DC(), test_ID3DXRenderToSurface(), test_scans(), ToMouseCoordinates(), TuiCalcMenuBoxSize(), TuiDrawProgressBarCenter(), UefiConsPutChar(), UefiVideoGetDisplaySize(), UITOOLS95_DFC_ButtonCheckRadio(), UITOOLS_MakeSquareRect(), VgaConsoleCreateGraphicsScreen(), VgaWriteTextModeFont(), VidBufferToScreenBlt(), VideoRenderer_OnSize(), VideoWindow_put_Height(), VideoWindow_SetWindowPosition(), VidScreenToBufferBlt(), VMR9_OnSize(), WebBrowser_put_Height(), wWinMain(), XboxConsPutChar(), and XboxVideoGetDisplaySize().

◆ hFont

_In_ HFONT hFont

Definition at line 87 of file font.h.

Referenced by _Success_(), add_ruler_units(), AddCharToSelection(), AddDialogControl(), BUTTON_CalcLabelRect(), C1_SetData(), CB_Paint(), check_height_font_enumproc(), ChildWndProc(), COMBO_Font(), COMCTL32_GetFontMetrics(), create_tabcontrol(), CreateConsoleFont2(), CreateConsoleFontEx(), CreateFontset(), CreateLayoutIcon(), CreateMonospaceFont(), CreateTitleFont(), CreateTrayIcon(), CUIFToolbarMenuButton::CUIFToolbarMenuButton(), D3DXCreateTextTest(), DlgProc(), DoEntry(), DoTestEntry(), DrawCaptionTempA(), DrawCaptionTempW(), DrawProc(), DrawThemeText(), DumpFont(), EditTypeDlg_OnDrawItem(), EMFDRV_CreateFontIndirect(), EMFDRV_SelectFont(), EnumEnhMetaFile(), EnumMetaFile(), FillFontStyleComboList(), fnIMLangFontLink2_ReleaseFont(), fnIMLangFontLink_ReleaseFont(), font_height(), FontSizeChange(), ftGdiGetGlyphOutline(), ftGdiGetTextCharsetInfo(), GB_Paint(), GetButtonHeight(), GetFontMetrics(), GetPhysicalFontHeight(), CTipbarThread::GetTextSize(), GetThemeTextExtent(), GetThemeTextMetrics(), HEADER_CreateDragImage(), HEADER_Refresh(), HEADER_SetFont(), HEXEDIT_WM_SETFONT(), HOTKEY_SetFont(), InatCreateIconBySize(), InitFonts(), InitInstance(), InternalSelectEx(), IPADDRESS_Create(), LISTVIEW_Command(), LISTVIEW_GetItemMetrics(), LISTVIEW_GetStringWidthT(), LISTVIEW_SaveTextMetrics(), LISTVIEW_SetFont(), LISTVIEW_ShowFocusRect(), LoadIniFile(), LrgCellWndProc(), MainFrameBase::MainFrameBase(), MainWndProc(), ME_DebugWrite(), MENU_DrawPopupGlyph(), MFDRV_CreateFontIndirect(), MonSelChangeFont(), MonSelGetMonitorFont(), MonSelPaintMonitor(), MonthCalChangeFont(), msi_dialog_get_sans_serif_height(), MyDrawCaptionTemp(), MyDrawFrameCaption(), MyDrawFrameScroll(), MyEnumFontFamExProc(), NOTEPAD_LoadSettingsFromRegistry(), NT5_DrawLogoffCaptionText(), NtGdiGetCharABCWidthsW(), NtGdiGetCharWidthW(), NtGdiGetFontData(), NtGdiGetFontUnicodeRanges(), NtGdiGetGlyphIndicesW(), NtGdiGetOutlineTextMetricsInternalW(), NtGdiGetTextFaceW(), NtUserDrawCaptionTemp(), NtUserDrawMenuBarTemp(), OB_Paint(), OnMeasureItem(), OSK_ChooseFont(), PB_Paint(), PlotCharacter(), PROGRESS_SetFont(), RealizeFontInit(), RefreshFontPreview(), RetChangeControlFont(), RosImageProc(), CACListView::SetFont(), ATL::CWindow::SetFont(), SetLrgFont(), CUIFMenu::SetMenuFont(), SetMessageFont(), SetupControls(), SoftModalMessageBox(), START_TEST(), STATIC_PaintTextfn(), SYSLINK_SetFont(), T1_GetTextMetric(), T1_SetData(), TAB_DrawItemInterior(), TAB_SetItemBounds(), test_bitmap_font_glyph_index(), test_combo_setfont(), Test_CreateFontA(), Test_CreateFontIndirectA(), Test_CreateFontIndirectExA(), Test_CreateFontIndirectExW(), Test_CreateFontIndirectW(), test_DrawTextCalcRect(), test_emf_ExtTextOut_on_path(), test_ExtTextOut(), Test_Font(), Test_FontSelectionEntry(), Test_GdiGetCharDimensions(), Test_GetTextFaceAliasW(), test_height(), test_MessageBoxFontTest(), test_mf_SaveDC(), test_SaveDC(), test_setfont(), ThemeDrawCaptionText(), TOOLBAR_SetFont(), TOOLTIPS_SetFont(), TreeListEditLabel(), TreeListProc(), TREEVIEW_Command(), TREEVIEW_SetFont(), UB_Paint(), UITOOLS95_DFC_ButtonCheckRadio(), UITOOLS95_DrawFrameCaption(), UITOOLS95_DrawFrameMenu(), UITOOLS95_DrawFrameScroll(), UpdateFontPreview(), UserDrawCaption(), UserDrawCaptionText(), and WndProc().

◆ Width

Definition at line 89 of file font.h.

Referenced by _Success_(), AcpiHwReadPort(), AcpiHwWritePort(), AcpiOsReadMemory(), AcpiOsReadPciConfiguration(), AcpiOsReadPort(), AcpiOsWriteMemory(), AcpiOsWritePciConfiguration(), AcpiOsWritePort(), AcpiUtFormatNumber(), CAppsListView::AddColumn(), CDowloadingAppsListView::AddColumn(), BaseControlVideoImpl_SetDestinationPosition(), BaseControlVideoImpl_SetSourcePosition(), BaseControlWindowImpl_put_Width(), BaseControlWindowImpl_SetWindowPosition(), BaseWindowImpl_OnSize(), BasicVideo_SetDestinationPosition(), BasicVideo_SetSourcePosition(), BitBlt(), BlDisplayValidOemBitmap(), cdtInit(), ChangeView(), co_IntShowDesktop(), ConioCopyRegion(), ConsolepClearBuffer(), ConvertBmpToGopBlt(), ConWndProc(), copy_interlaced_pixels(), CreateBitmap(), CreateCompatibleBitmap(), CreateConsoleFont2(), CreateConsoleFontEx(), CreateD3D9MipMap(), CreateDIBitmap(), CreateDiscardableBitmap(), CreatePopupWindow(), DECLARE_INTERFACE_(), DIB_1BPP_BitBltSrcCopy_From1BPP(), draw_diag_edge(), DrawBox(), DrawClassicFrame(), DrawListEntries(), DrawPartitionList(), FromMouseCoordinates(), GdipAddPathRectangles(), GdipAddPathRectanglesI(), GdipDrawRectanglesI(), GdipFillRectanglesI(), GuiGetLargestConsoleWindowSize(), HardwareDlgResize(), HistoryDisplayCurrentHistory(), i386PrintText(), IDirect3DDevice9Base_CreateTexture(), InbvBufferToScreenBlt(), InbvScreenToBufferBlt(), InitGL(), InitImageList(), InitMetrics(), IntCreateCompatibleBitmap(), IntDrawArc(), IntDrawDiagEdge(), IntDrawEllipse(), IntEngEnter(), IntEngFillBox(), InternetExplorer_put_Width(), IntFillArc(), IntFillEllipse(), IntFillRect(), IntGdiCreateMaskFromRLE(), IntPatBlt(), LISTVIEW_Size(), LlbFwVideoGetDisplaySize(), CGridView::MapWndProc(), MediaDet_GetBitmapBits(), MediaDet_WriteBitmapBits(), METAFILE_FillRectangles(), MiniTuiDrawProgressBarCenter(), MirrorRgnByWidth(), MyMakeSquareRect(), NC_DrawFrame(), NtGdiBitBlt(), NtGdiCreateCompatibleBitmap(), NtGdiCreatePen(), NtGdiRoundRect(), NtGdiSetBitmapDimension(), NtGdiSetDIBitsToDeviceInternal(), Pc98VideoGetDisplaySize(), PcVideoGetDisplaySize(), PopupError(), PrintDiskData(), PrintEmptyLine(), PrintPartitionData(), ProcessDisplayRegistry(), CAppInfoDisplay::ResizeChildren(), ResizeControls(), ResizeConWnd(), ReSizeGLScene(), ResizeTextConsole(), RleBitBlt(), SetDIBitsToDevice(), ShellUIHelper2_AddDesktopComponent(), Defragment::Start(), test_D3DXCreateRenderToSurface(), test_excludeinfinite(), test_Get_Release_DC(), test_ID3DXRenderToSurface(), test_scans(), ToMouseCoordinates(), TuiCalcMenuBoxSize(), TuiDrawProgressBarCenter(), UefiConsPutChar(), UefiVideoGetDisplaySize(), UITOOLS95_DFC_ButtonCheckRadio(), UITOOLS_MakeSquareRect(), VgaConsoleCreateGraphicsScreen(), VidBufferToScreenBlt(), VideoRenderer_OnSize(), VideoWindow_put_Width(), VideoWindow_SetWindowPosition(), VidScreenToBufferBlt(), VMR9_OnSize(), vsnprintf(), WebBrowser_put_Width(), wWinMain(), XboxConsPutChar(), and XboxVideoGetDisplaySize().