mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 08:25:03 +00:00
[CONCFG:FONT] Convert the TT_FONT_ENTRY structure to one similar to MS Terminal's _TT_FONT_LIST. (#4337)
See the definition of struct _TT_FONT_LIST in https://github.com/microsoft/terminal/blob/main/dep/Console/winconp.h Add Doxygen documentation. [CONSOLE.CPL][CONSRV] "fonts cache" -> "font cache".
This commit is contained in:
parent
5d3915d0fc
commit
0b6b0b0021
4 changed files with 50 additions and 30 deletions
|
@ -227,7 +227,7 @@ InitApplet(HANDLE hSectionOrWnd)
|
||||||
InitDefaultConsoleInfo(ConInfo);
|
InitDefaultConsoleInfo(ConInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize the font support -- additional TrueType fonts cache and current preview font */
|
/* Initialize the font support -- additional TrueType font cache and current preview font */
|
||||||
InitTTFontCache();
|
InitTTFontCache();
|
||||||
RefreshFontPreview(&FontPreview, ConInfo);
|
RefreshFontPreview(&FontPreview, ConInfo);
|
||||||
|
|
||||||
|
|
|
@ -26,8 +26,8 @@
|
||||||
|
|
||||||
#define TERMINAL_FACENAME L"Terminal"
|
#define TERMINAL_FACENAME L"Terminal"
|
||||||
|
|
||||||
// RTL_STATIC_LIST_HEAD(TTFontCache);
|
/* TrueType font list cache */
|
||||||
LIST_ENTRY TTFontCache = {&TTFontCache, &TTFontCache};
|
SINGLE_LIST_ENTRY TTFontCache = { NULL };
|
||||||
|
|
||||||
// NOTE: Used to tag code that makes sense only with a font cache.
|
// NOTE: Used to tag code that makes sense only with a font cache.
|
||||||
// #define FONT_CACHE_PRESENT
|
// #define FONT_CACHE_PRESENT
|
||||||
|
@ -952,15 +952,20 @@ IsValidConsoleFont(
|
||||||
return Param.IsValidFont;
|
return Param.IsValidFont;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
|
/**
|
||||||
|
* @brief
|
||||||
|
* Initializes the console TrueType font cache.
|
||||||
|
*
|
||||||
|
* @remark
|
||||||
* To install additional TrueType fonts to be available for the console,
|
* To install additional TrueType fonts to be available for the console,
|
||||||
* add entries of type REG_SZ named "0", "00" etc... in:
|
* add entries of type REG_SZ named "0", "00" etc... in:
|
||||||
* HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Console\TrueTypeFont
|
* HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Console\TrueTypeFont
|
||||||
* The names of the fonts listed there should match those in:
|
* The names of the fonts listed there should match those in:
|
||||||
* HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Fonts
|
* HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Fonts
|
||||||
*
|
*
|
||||||
* This function initializes the cache of the fonts listed there.
|
* @return None.
|
||||||
*/
|
**/
|
||||||
VOID
|
VOID
|
||||||
InitTTFontCache(VOID)
|
InitTTFontCache(VOID)
|
||||||
{
|
{
|
||||||
|
@ -975,9 +980,9 @@ InitTTFontCache(VOID)
|
||||||
PTT_FONT_ENTRY FontEntry;
|
PTT_FONT_ENTRY FontEntry;
|
||||||
PWCHAR pszNext;
|
PWCHAR pszNext;
|
||||||
|
|
||||||
if (!IsListEmpty(&TTFontCache))
|
if (TTFontCache.Next != NULL)
|
||||||
return;
|
return;
|
||||||
// InitializeListHead(&TTFontCache);
|
// TTFontCache.Next = NULL;
|
||||||
|
|
||||||
/* Open the Console\TrueTypeFont key */
|
/* Open the Console\TrueTypeFont key */
|
||||||
// "\\Registry\\Machine\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Console\\TrueTypeFont"
|
// "\\Registry\\Machine\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Console\\TrueTypeFont"
|
||||||
|
@ -1034,7 +1039,7 @@ InitTTFontCache(VOID)
|
||||||
pszNext = szValue;
|
pszNext = szValue;
|
||||||
|
|
||||||
/* Check whether bold is disabled for this font */
|
/* Check whether bold is disabled for this font */
|
||||||
if (*pszNext == L'*')
|
if (*pszNext == BOLD_MARK)
|
||||||
{
|
{
|
||||||
FontEntry->DisableBold = TRUE;
|
FontEntry->DisableBold = TRUE;
|
||||||
++pszNext;
|
++pszNext;
|
||||||
|
@ -1054,7 +1059,7 @@ InitTTFontCache(VOID)
|
||||||
pszNext += wcslen(pszNext) + 1;
|
pszNext += wcslen(pszNext) + 1;
|
||||||
|
|
||||||
/* Check whether bold is disabled for this font */
|
/* Check whether bold is disabled for this font */
|
||||||
if (*pszNext == L'*')
|
if (*pszNext == BOLD_MARK)
|
||||||
{
|
{
|
||||||
FontEntry->DisableBold = TRUE;
|
FontEntry->DisableBold = TRUE;
|
||||||
++pszNext;
|
++pszNext;
|
||||||
|
@ -1066,28 +1071,41 @@ InitTTFontCache(VOID)
|
||||||
pszNext, wcslen(pszNext));
|
pszNext, wcslen(pszNext));
|
||||||
}
|
}
|
||||||
|
|
||||||
InsertTailList(&TTFontCache, &FontEntry->Entry);
|
PushEntryList(&TTFontCache, &FontEntry->Entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Close the key and quit */
|
/* Close the key and quit */
|
||||||
RegCloseKey(hKey);
|
RegCloseKey(hKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief
|
||||||
|
* Clears the console TrueType font cache.
|
||||||
|
*
|
||||||
|
* @return None.
|
||||||
|
**/
|
||||||
VOID
|
VOID
|
||||||
ClearTTFontCache(VOID)
|
ClearTTFontCache(VOID)
|
||||||
{
|
{
|
||||||
PLIST_ENTRY Entry;
|
PSINGLE_LIST_ENTRY Entry;
|
||||||
PTT_FONT_ENTRY FontEntry;
|
PTT_FONT_ENTRY FontEntry;
|
||||||
|
|
||||||
while (!IsListEmpty(&TTFontCache))
|
while (TTFontCache.Next != NULL)
|
||||||
{
|
{
|
||||||
Entry = RemoveHeadList(&TTFontCache);
|
Entry = PopEntryList(&TTFontCache);
|
||||||
FontEntry = CONTAINING_RECORD(Entry, TT_FONT_ENTRY, Entry);
|
FontEntry = CONTAINING_RECORD(Entry, TT_FONT_ENTRY, Entry);
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, FontEntry);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, FontEntry);
|
||||||
}
|
}
|
||||||
InitializeListHead(&TTFontCache);
|
TTFontCache.Next = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief
|
||||||
|
* Refreshes the console TrueType font cache,
|
||||||
|
* by clearing and re-initializing it.
|
||||||
|
*
|
||||||
|
* @return None.
|
||||||
|
**/
|
||||||
VOID
|
VOID
|
||||||
RefreshTTFontCache(VOID)
|
RefreshTTFontCache(VOID)
|
||||||
{
|
{
|
||||||
|
@ -1101,13 +1119,13 @@ FindCachedTTFont(
|
||||||
_In_ PCWSTR FaceName,
|
_In_ PCWSTR FaceName,
|
||||||
_In_ UINT CodePage)
|
_In_ UINT CodePage)
|
||||||
{
|
{
|
||||||
PLIST_ENTRY Entry;
|
PSINGLE_LIST_ENTRY Entry;
|
||||||
PTT_FONT_ENTRY FontEntry;
|
PTT_FONT_ENTRY FontEntry;
|
||||||
|
|
||||||
/* Search for the font in the cache */
|
/* Search for the font in the cache */
|
||||||
for (Entry = TTFontCache.Flink;
|
for (Entry = TTFontCache.Next;
|
||||||
Entry != &TTFontCache;
|
Entry != NULL;
|
||||||
Entry = Entry->Flink)
|
Entry = Entry->Next)
|
||||||
{
|
{
|
||||||
FontEntry = CONTAINING_RECORD(Entry, TT_FONT_ENTRY, Entry);
|
FontEntry = CONTAINING_RECORD(Entry, TT_FONT_ENTRY, Entry);
|
||||||
|
|
||||||
|
|
|
@ -59,9 +59,19 @@
|
||||||
#define IsBoldFont(Weight) \
|
#define IsBoldFont(Weight) \
|
||||||
((Weight) >= FW_SEMIBOLD) /* Sometimes, just > FW_MEDIUM */
|
((Weight) >= FW_SEMIBOLD) /* Sometimes, just > FW_MEDIUM */
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @struct TrueType font list, cached from
|
||||||
|
* HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Console\TrueTypeFont
|
||||||
|
*
|
||||||
|
* See the definition of struct _TT_FONT_LIST
|
||||||
|
* in https://github.com/microsoft/terminal/blob/main/dep/Console/winconp.h
|
||||||
|
*/
|
||||||
|
#define BOLD_MARK L'*'
|
||||||
|
|
||||||
typedef struct _TT_FONT_ENTRY
|
typedef struct _TT_FONT_ENTRY
|
||||||
{
|
{
|
||||||
LIST_ENTRY Entry;
|
SINGLE_LIST_ENTRY Entry;
|
||||||
UINT CodePage;
|
UINT CodePage;
|
||||||
BOOL DisableBold;
|
BOOL DisableBold;
|
||||||
WCHAR FaceName[LF_FACESIZE];
|
WCHAR FaceName[LF_FACESIZE];
|
||||||
|
@ -128,15 +138,7 @@ IsValidConsoleFont(
|
||||||
_In_ PCWSTR FaceName,
|
_In_ PCWSTR FaceName,
|
||||||
_In_ UINT CodePage);
|
_In_ UINT CodePage);
|
||||||
|
|
||||||
/*
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
* This function initializes the cache of the fonts listed there.
|
|
||||||
*/
|
|
||||||
VOID
|
VOID
|
||||||
InitTTFontCache(VOID);
|
InitTTFontCache(VOID);
|
||||||
|
|
||||||
|
|
|
@ -301,7 +301,7 @@ GuiInit(IN PCONSOLE_INIT_INFO ConsoleInitInfo,
|
||||||
/* Initialize and register the console window class */
|
/* Initialize and register the console window class */
|
||||||
if (!RegisterConWndClass(ConSrvDllInstance)) return FALSE;
|
if (!RegisterConWndClass(ConSrvDllInstance)) return FALSE;
|
||||||
|
|
||||||
/* Initialize the font support -- additional TrueType fonts cache */
|
/* Initialize the font support -- additional TrueType font cache */
|
||||||
InitTTFontCache();
|
InitTTFontCache();
|
||||||
|
|
||||||
ConsInitialized = TRUE;
|
ConsInitialized = TRUE;
|
||||||
|
|
Loading…
Reference in a new issue