Commit a84c60ed authored by Alexandre Julliard's avatar Alexandre Julliard

gdi32: Add a separate backend function to load the font list.

parent fc44dcdd
......@@ -3238,13 +3238,22 @@ static void init_font_options(void)
*/
void font_init(void)
{
static const WCHAR mutex_nameW[] = {'_','_','W','I','N','E','_','F','O','N','T','_','M','U','T','E','X','_','_',0};
HANDLE mutex;
if (RegCreateKeyExA( HKEY_CURRENT_USER, "Software\\Wine\\Fonts", 0, NULL, 0,
KEY_ALL_ACCESS, NULL, &wine_fonts_key, NULL ))
return;
init_font_options();
update_codepage();
WineEngInit( &font_funcs );
if (!WineEngInit( &font_funcs )) return;
if (!(mutex = CreateMutexW( NULL, FALSE, mutex_nameW ))) return;
WaitForSingleObject( mutex, INFINITE );
font_funcs->load_fonts();
ReleaseMutex( mutex );
reorder_font_list();
load_gdi_font_subst();
load_gdi_font_replacements();
......
......@@ -286,8 +286,6 @@ static struct list mappings_list = LIST_INIT( mappings_list );
static UINT default_aa_flags;
static HKEY hkey_font_cache;
static const WCHAR font_mutex_nameW[] = {'_','_','W','I','N','E','_','F','O','N','T','_','M','U','T','E','X','_','_','\0'};
static BOOL CDECL freetype_set_outline_text_metrics( struct gdi_font *font );
static BOOL CDECL freetype_set_bitmap_text_metrics( struct gdi_font *font );
static void remove_face_from_cache( Face *face );
......@@ -2168,29 +2166,11 @@ static void init_font_list(void)
}
/*************************************************************
* WineEngInit
*
* Initialize FreeType library and create a list of available faces
* freetype_load_fonts
*/
BOOL WineEngInit( const struct font_backend_funcs **funcs )
static void CDECL freetype_load_fonts(void)
{
DWORD disposition;
HANDLE font_mutex;
if(!init_freetype()) return FALSE;
#ifdef SONAME_LIBFONTCONFIG
init_fontconfig();
#endif
*funcs = &font_funcs;
if((font_mutex = CreateMutexW(NULL, FALSE, font_mutex_nameW)) == NULL)
{
ERR("Failed to create font mutex\n");
return FALSE;
}
WaitForSingleObject(font_mutex, INFINITE);
create_font_cache_key(&hkey_font_cache, &disposition);
......@@ -2201,8 +2181,22 @@ BOOL WineEngInit( const struct font_backend_funcs **funcs )
if(disposition == REG_CREATED_NEW_KEY)
update_reg_entries();
}
/*************************************************************
* WineEngInit
*
* Initialize FreeType library and create a list of available faces
*/
BOOL WineEngInit( const struct font_backend_funcs **funcs )
{
if(!init_freetype()) return FALSE;
#ifdef SONAME_LIBFONTCONFIG
init_fontconfig();
#endif
ReleaseMutex(font_mutex);
*funcs = &font_funcs;
return TRUE;
}
......@@ -5020,6 +5014,7 @@ static DWORD CDECL freetype_get_kerning_pairs( struct gdi_font *font, KERNINGPAI
static const struct font_backend_funcs font_funcs =
{
freetype_SelectFont,
freetype_load_fonts,
freetype_add_font,
freetype_add_mem_font,
freetype_remove_font,
......
......@@ -427,6 +427,7 @@ struct font_backend_funcs
{
struct gdi_font * (CDECL *pSelectFont)( DC *dc, HFONT hfont );
void (CDECL *load_fonts)(void);
INT (CDECL *add_font)( const WCHAR *file, DWORD flags );
INT (CDECL *add_mem_font)( void *ptr, SIZE_T size, DWORD flags );
BOOL (CDECL *remove_font)( const WCHAR *file, DWORD flags );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment