https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0b6b0b0021d37f63e5eec7f69ce7bdc678951098

commit 0b6b0b0021d37f63e5eec7f69ce7bdc678951098
Author:     Hermès Bélusca-Maïto <[email protected]>
AuthorDate: Mon Jul 5 20:07:21 2021 +0200
Commit:     Hermès Bélusca-Maïto <[email protected]>
CommitDate: Tue Feb 8 15:59:08 2022 +0100

    [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".
---
 dll/cpl/console/console.c                          |  2 +-
 win32ss/user/winsrv/concfg/font.c                  | 54 ++++++++++++++--------
 win32ss/user/winsrv/concfg/font.h                  | 22 +++++----
 win32ss/user/winsrv/consrv/frontends/gui/guiterm.c |  2 +-
 4 files changed, 50 insertions(+), 30 deletions(-)

diff --git a/dll/cpl/console/console.c b/dll/cpl/console/console.c
index 65640bc9282..077ff3a9278 100644
--- a/dll/cpl/console/console.c
+++ b/dll/cpl/console/console.c
@@ -227,7 +227,7 @@ InitApplet(HANDLE hSectionOrWnd)
         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();
     RefreshFontPreview(&FontPreview, ConInfo);
 
diff --git a/win32ss/user/winsrv/concfg/font.c 
b/win32ss/user/winsrv/concfg/font.c
index 59b12e3ae90..485126a4928 100644
--- a/win32ss/user/winsrv/concfg/font.c
+++ b/win32ss/user/winsrv/concfg/font.c
@@ -26,8 +26,8 @@
 
 #define TERMINAL_FACENAME   L"Terminal"
 
-// RTL_STATIC_LIST_HEAD(TTFontCache);
-LIST_ENTRY TTFontCache = {&TTFontCache, &TTFontCache};
+/* TrueType font list cache */
+SINGLE_LIST_ENTRY TTFontCache = { NULL };
 
 // NOTE: Used to tag code that makes sense only with a font cache.
 // #define FONT_CACHE_PRESENT
@@ -952,15 +952,20 @@ IsValidConsoleFont(
     return Param.IsValidFont;
 }
 
-/*
+
+/**
+ * @brief
+ * Initializes the console TrueType font cache.
+ *
+ * @remark
  * 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.
- */
+ * @return None.
+ **/
 VOID
 InitTTFontCache(VOID)
 {
@@ -975,9 +980,9 @@ InitTTFontCache(VOID)
     PTT_FONT_ENTRY FontEntry;
     PWCHAR pszNext;
 
-    if (!IsListEmpty(&TTFontCache))
+    if (TTFontCache.Next != NULL)
         return;
-    // InitializeListHead(&TTFontCache);
+    // TTFontCache.Next = NULL;
 
     /* Open the Console\TrueTypeFont key */
     // "\\Registry\\Machine\\Software\\Microsoft\\Windows 
NT\\CurrentVersion\\Console\\TrueTypeFont"
@@ -1034,7 +1039,7 @@ InitTTFontCache(VOID)
         pszNext = szValue;
 
         /* Check whether bold is disabled for this font */
-        if (*pszNext == L'*')
+        if (*pszNext == BOLD_MARK)
         {
             FontEntry->DisableBold = TRUE;
             ++pszNext;
@@ -1054,7 +1059,7 @@ InitTTFontCache(VOID)
             pszNext += wcslen(pszNext) + 1;
 
             /* Check whether bold is disabled for this font */
-            if (*pszNext == L'*')
+            if (*pszNext == BOLD_MARK)
             {
                 FontEntry->DisableBold = TRUE;
                 ++pszNext;
@@ -1066,28 +1071,41 @@ InitTTFontCache(VOID)
                             pszNext, wcslen(pszNext));
         }
 
-        InsertTailList(&TTFontCache, &FontEntry->Entry);
+        PushEntryList(&TTFontCache, &FontEntry->Entry);
     }
 
     /* Close the key and quit */
     RegCloseKey(hKey);
 }
 
+/**
+ * @brief
+ * Clears the console TrueType font cache.
+ *
+ * @return None.
+ **/
 VOID
 ClearTTFontCache(VOID)
 {
-    PLIST_ENTRY Entry;
+    PSINGLE_LIST_ENTRY Entry;
     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);
         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
 RefreshTTFontCache(VOID)
 {
@@ -1101,13 +1119,13 @@ FindCachedTTFont(
     _In_ PCWSTR FaceName,
     _In_ UINT CodePage)
 {
-    PLIST_ENTRY Entry;
+    PSINGLE_LIST_ENTRY Entry;
     PTT_FONT_ENTRY FontEntry;
 
     /* Search for the font in the cache */
-    for (Entry = TTFontCache.Flink;
-         Entry != &TTFontCache;
-         Entry = Entry->Flink)
+    for (Entry = TTFontCache.Next;
+         Entry != NULL;
+         Entry = Entry->Next)
     {
         FontEntry = CONTAINING_RECORD(Entry, TT_FONT_ENTRY, Entry);
 
diff --git a/win32ss/user/winsrv/concfg/font.h 
b/win32ss/user/winsrv/concfg/font.h
index 6faa59dad33..bff2107a7c8 100644
--- a/win32ss/user/winsrv/concfg/font.h
+++ b/win32ss/user/winsrv/concfg/font.h
@@ -59,9 +59,19 @@
 #define IsBoldFont(Weight)  \
     ((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
 {
-    LIST_ENTRY Entry;
+    SINGLE_LIST_ENTRY Entry;
     UINT CodePage;
     BOOL DisableBold;
     WCHAR FaceName[LF_FACESIZE];
@@ -128,15 +138,7 @@ IsValidConsoleFont(
     _In_ PCWSTR FaceName,
     _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
 InitTTFontCache(VOID);
 
diff --git a/win32ss/user/winsrv/consrv/frontends/gui/guiterm.c 
b/win32ss/user/winsrv/consrv/frontends/gui/guiterm.c
index 0594ff4a0c8..f272b57acf0 100644
--- a/win32ss/user/winsrv/consrv/frontends/gui/guiterm.c
+++ b/win32ss/user/winsrv/consrv/frontends/gui/guiterm.c
@@ -301,7 +301,7 @@ GuiInit(IN PCONSOLE_INIT_INFO ConsoleInitInfo,
         /* Initialize and register the console window class */
         if (!RegisterConWndClass(ConSrvDllInstance)) return FALSE;
 
-        /* Initialize the font support -- additional TrueType fonts cache */
+        /* Initialize the font support -- additional TrueType font cache */
         InitTTFontCache();
 
         ConsInitialized = TRUE;

Reply via email to