gdi32: Only use the registry cache for application fonts.

And load system fonts outside of the global font mutex. We now only use
the mutex to protect the registry fonts initialization.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Rémi Bernon 2020-11-27 15:38:05 +01:00 committed by Alexandre Julliard
parent cae74aa7d9
commit 63de94839c
2 changed files with 19 additions and 13 deletions

View File

@ -7758,7 +7758,7 @@ static void load_system_bitmap_fonts(void)
{
dlen = sizeof(data);
if (!RegQueryValueExW( hkey, fonts[i], 0, &type, (BYTE *)data, &dlen ) && type == REG_SZ)
add_system_font_resource( data, ADDFONT_ALLOW_BITMAP | ADDFONT_ADD_TO_CACHE );
add_system_font_resource( data, ADDFONT_ALLOW_BITMAP );
}
RegCloseKey( hkey );
}
@ -7789,11 +7789,11 @@ static void load_file_system_fonts(void)
/* Windows directory */
get_fonts_win_dir_path( L"*", path );
load_directory_fonts( path, ADDFONT_ADD_TO_CACHE );
load_directory_fonts( path, 0 );
/* Wine data directory */
get_fonts_data_dir_path( L"*", path );
load_directory_fonts( path, ADDFONT_ADD_TO_CACHE | ADDFONT_EXTERNAL_FONT );
load_directory_fonts( path, ADDFONT_EXTERNAL_FONT );
/* custom paths */
/* @@ Wine registry key: HKCU\Software\Wine\Fonts */
@ -7805,7 +7805,7 @@ static void load_file_system_fonts(void)
if (next && next - ptr < 2) continue;
lstrcpynW( path, ptr, MAX_PATH - 2 );
lstrcatW( path, L"\\*" );
load_directory_fonts( path, ADDFONT_ADD_TO_CACHE | ADDFONT_EXTERNAL_FONT );
load_directory_fonts( path, ADDFONT_EXTERNAL_FONT );
}
}
}
@ -7926,9 +7926,9 @@ static void load_registry_fonts(void)
dlen /= sizeof(WCHAR);
if (data[0] && data[1] == ':')
add_font_resource( data, ADDFONT_ALLOW_BITMAP | ADDFONT_ADD_TO_CACHE );
add_font_resource( data, ADDFONT_ALLOW_BITMAP );
else if (dlen >= 6 && !wcsicmp( data + dlen - 5, L".fon" ))
add_system_font_resource( data, ADDFONT_ALLOW_BITMAP | ADDFONT_ADD_TO_CACHE );
add_system_font_resource( data, ADDFONT_ALLOW_BITMAP );
next:
vlen = ARRAY_SIZE(value);
dlen = sizeof(data);
@ -7954,6 +7954,10 @@ void font_init(void)
update_codepage();
if (__wine_init_unix_lib( gdi32_module, DLL_PROCESS_ATTACH, &callback_funcs, &font_funcs )) return;
load_system_bitmap_fonts();
load_file_system_fonts();
font_funcs->load_fonts();
if (!(mutex = CreateMutexW( NULL, FALSE, L"__WINE_FONT_MUTEX__" ))) return;
WaitForSingleObject( mutex, INFINITE );
@ -7962,16 +7966,18 @@ void font_init(void)
if (disposition == REG_CREATED_NEW_KEY)
{
load_system_bitmap_fonts();
load_file_system_fonts();
font_funcs->load_fonts();
load_registry_fonts();
update_external_font_keys();
}
else load_font_list_from_cache();
ReleaseMutex( mutex );
if (disposition != REG_CREATED_NEW_KEY)
{
load_registry_fonts();
load_font_list_from_cache();
}
reorder_font_list();
load_gdi_font_subst();
load_gdi_font_replacements();

View File

@ -1303,7 +1303,7 @@ static BOOL ReadFontDir(const char *dirname, BOOL external_fonts)
ReadFontDir(path, external_fonts);
else
{
DWORD addfont_flags = ADDFONT_ADD_TO_CACHE;
DWORD addfont_flags = 0;
if(external_fonts) addfont_flags |= ADDFONT_EXTERNAL_FONT;
AddFontToList(NULL, path, NULL, 0, addfont_flags);
}
@ -1523,7 +1523,7 @@ static void load_fontconfig_fonts( void )
if (!(done_set = pFcStrSetCreate())) goto done;
if (!(dir_list = pFcConfigGetFontDirs( config ))) goto done;
fontconfig_add_fonts_from_dir_list( config, dir_list, done_set, ADDFONT_EXTERNAL_FONT | ADDFONT_ADD_TO_CACHE );
fontconfig_add_fonts_from_dir_list( config, dir_list, done_set, ADDFONT_EXTERNAL_FONT );
done:
if (dir_list) pFcStrListDone( dir_list );
@ -1543,7 +1543,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(NULL, path, NULL, 0, ADDFONT_EXTERNAL_FONT | ADDFONT_ADD_TO_CACHE);
AddFontToList(NULL, path, NULL, 0, ADDFONT_EXTERNAL_FONT);
}
RtlFreeHeap(GetProcessHeap(), 0, path);
}