Jacek Caban : gdi32: Directly use ntdll in add_font_list.

Alexandre Julliard julliard at winehq.org
Thu Sep 23 15:35:06 CDT 2021


Module: wine
Branch: master
Commit: 484aad56c8a5b38597e5316e6ca98fc781dbf15d
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=484aad56c8a5b38597e5316e6ca98fc781dbf15d

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Thu Sep 23 13:44:10 2021 +0100

gdi32: Directly use ntdll in add_font_list.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/gdi32/font.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/dlls/gdi32/font.c b/dlls/gdi32/font.c
index 1e3c70550a3..4b3c93d9853 100644
--- a/dlls/gdi32/font.c
+++ b/dlls/gdi32/font.c
@@ -132,6 +132,13 @@ static struct font_gamma_ramp font_gamma_ramp;
 static void add_face_to_cache( struct gdi_font_face *face );
 static void remove_face_from_cache( struct gdi_font_face *face );
 
+static UINT asciiz_to_unicode( WCHAR *dst, const char *src )
+{
+    WCHAR *p = dst;
+    while ((*p++ = *src++));
+    return (p - dst) * sizeof(WCHAR);
+}
+
 static inline WCHAR facename_tolower( WCHAR c )
 {
     if (c >= 'A' && c <= 'Z') return c - 'A' + 'a';
@@ -504,6 +511,13 @@ static void set_reg_value( HKEY hkey, const WCHAR *name, UINT type, const void *
     NtSetValueKey( hkey, &nameW, 0, type, value, count );
 }
 
+static void set_reg_ascii_value( HKEY hkey, const char *name, const char *value )
+{
+    WCHAR nameW[64], valueW[128];
+    asciiz_to_unicode( nameW, name );
+    set_reg_value( hkey, nameW, REG_SZ, valueW, asciiz_to_unicode( valueW, value ));
+}
+
 static ULONG query_reg_value( HKEY hkey, const WCHAR *name,
                               KEY_VALUE_PARTIAL_INFORMATION *info, ULONG size )
 {
@@ -2458,10 +2472,10 @@ static void add_font_list(HKEY hkey, const struct nls_update_font_list *fl, int
 {
     const char *sserif = (dpi <= 108) ? fl->sserif_96 : fl->sserif_120;
 
-    RegSetValueExA(hkey, "Courier", 0, REG_SZ, (const BYTE *)fl->courier, strlen(fl->courier)+1);
-    RegSetValueExA(hkey, "MS Serif", 0, REG_SZ, (const BYTE *)fl->serif, strlen(fl->serif)+1);
-    RegSetValueExA(hkey, "MS Sans Serif", 0, REG_SZ, (const BYTE *)sserif, strlen(sserif)+1);
-    RegSetValueExA(hkey, "Small Fonts", 0, REG_SZ, (const BYTE *)fl->small, strlen(fl->small)+1);
+    set_reg_ascii_value( hkey, "Courier", fl->courier );
+    set_reg_ascii_value( hkey, "MS Serif", fl->serif );
+    set_reg_ascii_value( hkey, "MS Sans Serif", sserif );
+    set_reg_ascii_value( hkey, "Small Fonts", fl->small );
 }
 
 static void set_value_key(HKEY hkey, const char *name, const char *value)




More information about the wine-cvs mailing list