From 08ea107ac1e709b091bbd1f7e22449944aef85db Mon Sep 17 00:00:00 2001 From: Daniel Lehman Date: Thu, 8 Mar 2018 11:53:17 -0800 Subject: [PATCH 2/2] gdi32: List fonts copied to C:\Windows\Fonts in registry. Signed-off-by: Daniel Lehman --- dlls/gdi32/freetype.c | 51 ++++++++++++++++++++++++++----------------------- dlls/gdi32/tests/font.c | 2 +- 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c index 1293e08..dfe9a23 100644 --- a/dlls/gdi32/freetype.c +++ b/dlls/gdi32/freetype.c @@ -282,11 +282,10 @@ typedef struct tagFace { struct enum_data *cached_enum_data; } Face; -#define ADDFONT_EXTERNAL_FONT 0x01 -#define ADDFONT_ALLOW_BITMAP 0x02 -#define ADDFONT_ADD_TO_CACHE 0x04 -#define ADDFONT_ADD_RESOURCE 0x08 /* added through AddFontResource */ -#define ADDFONT_VERTICAL_FONT 0x10 +#define ADDFONT_ALLOW_BITMAP 0x01 +#define ADDFONT_ADD_TO_CACHE 0x02 +#define ADDFONT_ADD_RESOURCE 0x04 /* added through AddFontResource */ +#define ADDFONT_VERTICAL_FONT 0x08 #define ADDFONT_AA_FLAGS(flags) ((flags) << 16) typedef struct tagFamily { @@ -2237,7 +2236,7 @@ static INT AddFontToList(const char *file, void *font_data_ptr, DWORD font_data_ INT ret = 0; /* we always load external fonts from files - otherwise we would get a crash in update_reg_entries */ - assert(file || !(flags & ADDFONT_EXTERNAL_FONT)); + assert(file); #ifdef HAVE_CARBON_CARBON_H if(file) @@ -2709,7 +2708,7 @@ skip_internal: return ret; } -static BOOL ReadFontDir(const char *dirname, BOOL external_fonts) +static BOOL ReadFontDir(const char *dirname) { DIR *dir; struct dirent *dent; @@ -2738,13 +2737,9 @@ static BOOL ReadFontDir(const char *dirname, BOOL external_fonts) continue; } if(S_ISDIR(statbuf.st_mode)) - ReadFontDir(path, external_fonts); + ReadFontDir(path); else - { - DWORD addfont_flags = ADDFONT_ADD_TO_CACHE; - if(external_fonts) addfont_flags |= ADDFONT_EXTERNAL_FONT; - AddFontToList(path, NULL, 0, addfont_flags); - } + AddFontToList(path, NULL, 0, ADDFONT_ADD_TO_CACHE); } closedir(dir); return TRUE; @@ -2859,7 +2854,7 @@ static void load_fontconfig_fonts(void) ext = &file[ len - 3 ]; if(strcasecmp(ext, "pfa") && strcasecmp(ext, "pfb")) AddFontToList(file, NULL, 0, - ADDFONT_EXTERNAL_FONT | ADDFONT_ADD_TO_CACHE | ADDFONT_AA_FLAGS(aa_flags) ); + ADDFONT_ADD_TO_CACHE | ADDFONT_AA_FLAGS(aa_flags) ); } pFcFontSetDestroy(fontset); pFcObjectSetDestroy(os); @@ -2879,7 +2874,7 @@ static void load_mac_font_callback(const void *value, void *context) if (path && CFStringGetFileSystemRepresentation(pathStr, path, len)) { TRACE("font file %s\n", path); - AddFontToList(path, NULL, 0, ADDFONT_EXTERNAL_FONT | ADDFONT_ADD_TO_CACHE); + AddFontToList(path, NULL, 0, ADDFONT_ADD_TO_CACHE); } HeapFree(GetProcessHeap(), 0, path); } @@ -3104,8 +3099,9 @@ static void update_reg_entries(void) DWORD len; Family *family; Face *face; - WCHAR *file, *path; + WCHAR *file, *path, fonts_dir[MAX_PATH]; static const WCHAR TrueType[] = {' ','(','T','r','u','e','T','y','p','e',')','\0'}; + static const WCHAR slashW[] = {'\\','\0'}; if(RegCreateKeyExW(HKEY_LOCAL_MACHINE, winnt_font_reg_key, 0, NULL, 0, KEY_ALL_ACCESS, NULL, &winnt_key, NULL) != ERROR_SUCCESS) { @@ -3125,6 +3121,10 @@ static void update_reg_entries(void) goto end; } + GetWindowsDirectoryW(fonts_dir, sizeof(fonts_dir) / sizeof(WCHAR)); + strcatW(fonts_dir, fontsW); + strcatW(fonts_dir, slashW); + /* enumerate the fonts and add external ones to the two keys */ LIST_FOR_EACH_ENTRY( family, &font_list, Family, entry ) { @@ -3132,8 +3132,6 @@ static void update_reg_entries(void) char *buffer; WCHAR *name; - if (!(face->flags & ADDFONT_EXTERNAL_FONT)) continue; - name = face->FullName ? face->FullName : family->FamilyName; len = strlenW(name) + 1; @@ -3151,7 +3149,12 @@ static void update_reg_entries(void) HeapFree( GetProcessHeap(), 0, buffer ); if (path) - file = path; + { + if (!strncmpiW(fonts_dir, path, lstrlenW(fonts_dir))) + file = path + lstrlenW(fonts_dir); + else + file = path; + } else if ((file = strrchrW(face->file, '/'))) file++; else @@ -4190,14 +4193,14 @@ static void init_font_list(void) strcatW(windowsdir, fontsW); if((unixname = wine_get_unix_file_name(windowsdir))) { - ReadFontDir(unixname, FALSE); + ReadFontDir(unixname); HeapFree(GetProcessHeap(), 0, unixname); } /* load the wine fonts */ if ((unixname = get_font_dir())) { - ReadFontDir(unixname, TRUE); + ReadFontDir(unixname); HeapFree(GetProcessHeap(), 0, unixname); } @@ -4261,7 +4264,7 @@ static void init_font_list(void) #elif defined(HAVE_CARBON_CARBON_H) load_mac_fonts(); #elif defined(__ANDROID__) - ReadFontDir("/system/fonts", TRUE); + ReadFontDir("/system/fonts"); #endif /* then look in any directories that we've specified in the config file */ @@ -4293,11 +4296,11 @@ static void init_font_list(void) { strcpy( unixname, home ); strcat( unixname, ptr + 1 ); - ReadFontDir( unixname, TRUE ); + ReadFontDir( unixname ); HeapFree( GetProcessHeap(), 0, unixname ); } else - ReadFontDir( ptr, TRUE ); + ReadFontDir( ptr ); ptr = next; } HeapFree( GetProcessHeap(), 0, valueA ); diff --git a/dlls/gdi32/tests/font.c b/dlls/gdi32/tests/font.c index af7778e..b9dcb69 100644 --- a/dlls/gdi32/tests/font.c +++ b/dlls/gdi32/tests/font.c @@ -6909,7 +6909,7 @@ static void test_fonts_key(void) if (!lstrcmpiW(font_names[j], finddata.cFileName)) break; } -todo_wine + ok(j < nnames, "%s exists on disk but not in registry\n", wine_dbgstr_w(finddata.cFileName)); } while (FindNextFileW(handle, &finddata)); FindClose(handle); -- 1.9.5