gdi32: Move the font list reordering out of freetype.c.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2020-11-03 11:25:47 +01:00
parent de63a647d5
commit fc44dcdd03
3 changed files with 62 additions and 75 deletions

View File

@ -225,6 +225,42 @@ static const WCHAR Gulim[] = {'G','u','l','i','m',0};
static const WCHAR PMingLiU[] = {'P','M','i','n','g','L','i','U',0}; static const WCHAR PMingLiU[] = {'P','M','i','n','g','L','i','U',0};
static const WCHAR Batang[] = {'B','a','t','a','n','g',0}; static const WCHAR Batang[] = {'B','a','t','a','n','g',0};
static const WCHAR arial[] = {'A','r','i','a','l',0};
static const WCHAR bitstream_vera_sans[] = {'B','i','t','s','t','r','e','a','m',' ','V','e','r','a',' ','S','a','n','s',0};
static const WCHAR bitstream_vera_sans_mono[] = {'B','i','t','s','t','r','e','a','m',' ','V','e','r','a',' ','S','a','n','s',' ','M','o','n','o',0};
static const WCHAR bitstream_vera_serif[] = {'B','i','t','s','t','r','e','a','m',' ','V','e','r','a',' ','S','e','r','i','f',0};
static const WCHAR courier_new[] = {'C','o','u','r','i','e','r',' ','N','e','w',0};
static const WCHAR liberation_mono[] = {'L','i','b','e','r','a','t','i','o','n',' ','M','o','n','o',0};
static const WCHAR liberation_sans[] = {'L','i','b','e','r','a','t','i','o','n',' ','S','a','n','s',0};
static const WCHAR liberation_serif[] = {'L','i','b','e','r','a','t','i','o','n',' ','S','e','r','i','f',0};
static const WCHAR times_new_roman[] = {'T','i','m','e','s',' ','N','e','w',' ','R','o','m','a','n',0};
static const WCHAR * const default_serif_list[] =
{
times_new_roman,
liberation_serif,
bitstream_vera_serif,
NULL
};
static const WCHAR * const default_fixed_list[] =
{
courier_new,
liberation_mono,
bitstream_vera_sans_mono,
NULL
};
static const WCHAR * const default_sans_list[] =
{
arial,
liberation_sans,
bitstream_vera_sans,
NULL
};
const WCHAR *default_serif = times_new_roman;
const WCHAR *default_fixed = courier_new;
const WCHAR *default_sans = arial;
static const struct nls_update_font_list static const struct nls_update_font_list
{ {
UINT ansi_cp, oem_cp; UINT ansi_cp, oem_cp;
@ -691,6 +727,28 @@ static void dump_gdi_font_list(void)
} }
} }
static const WCHAR *set_default_family( const WCHAR * const *name_list )
{
struct gdi_font_family *family;
const WCHAR * const *entry;
for (entry = name_list; *entry; entry++)
{
if (!(family = find_family_from_name( *entry ))) continue;
list_remove( &family->entry );
list_add_head( &font_list, &family->entry );
return *entry;
}
return *name_list;
}
static void reorder_font_list(void)
{
default_serif = set_default_family( default_serif_list );
default_fixed = set_default_family( default_fixed_list );
default_sans = set_default_family( default_sans_list );
}
struct gdi_font_face *create_face( const WCHAR *style, const WCHAR *fullname, const WCHAR *file, struct gdi_font_face *create_face( const WCHAR *style, const WCHAR *fullname, const WCHAR *file,
UINT index, FONTSIGNATURE fs, DWORD ntmflags, DWORD version, UINT index, FONTSIGNATURE fs, DWORD ntmflags, DWORD version,
DWORD flags, const struct bitmap_font_size *size ) DWORD flags, const struct bitmap_font_size *size )
@ -3187,6 +3245,7 @@ void font_init(void)
init_font_options(); init_font_options();
update_codepage(); update_codepage();
WineEngInit( &font_funcs ); WineEngInit( &font_funcs );
reorder_font_list();
load_gdi_font_subst(); load_gdi_font_subst();
load_gdi_font_replacements(); load_gdi_font_replacements();
load_system_links(); load_system_links();

View File

@ -263,46 +263,8 @@ static const WCHAR winnt_font_reg_key[] = {'S','o','f','t','w','a','r','e','\\',
static const WCHAR external_fonts_reg_key[] = {'S','o','f','t','w','a','r','e','\\','W','i','n','e','\\', static const WCHAR external_fonts_reg_key[] = {'S','o','f','t','w','a','r','e','\\','W','i','n','e','\\',
'F','o','n','t','s','\\','E','x','t','e','r','n','a','l',' ','F','o','n','t','s','\0'}; 'F','o','n','t','s','\\','E','x','t','e','r','n','a','l',' ','F','o','n','t','s','\0'};
/* Interesting and well-known (frequently-assumed!) font names */
static const WCHAR arial[] = {'A','r','i','a','l',0};
static const WCHAR bitstream_vera_sans[] = {'B','i','t','s','t','r','e','a','m',' ','V','e','r','a',' ','S','a','n','s',0};
static const WCHAR bitstream_vera_sans_mono[] = {'B','i','t','s','t','r','e','a','m',' ','V','e','r','a',' ','S','a','n','s',' ','M','o','n','o',0};
static const WCHAR bitstream_vera_serif[] = {'B','i','t','s','t','r','e','a','m',' ','V','e','r','a',' ','S','e','r','i','f',0};
static const WCHAR courier_new[] = {'C','o','u','r','i','e','r',' ','N','e','w',0};
static const WCHAR liberation_mono[] = {'L','i','b','e','r','a','t','i','o','n',' ','M','o','n','o',0};
static const WCHAR liberation_sans[] = {'L','i','b','e','r','a','t','i','o','n',' ','S','a','n','s',0};
static const WCHAR liberation_serif[] = {'L','i','b','e','r','a','t','i','o','n',' ','S','e','r','i','f',0};
static const WCHAR times_new_roman[] = {'T','i','m','e','s',' ','N','e','w',' ','R','o','m','a','n',0};
static const WCHAR SymbolW[] = {'S','y','m','b','o','l','\0'}; static const WCHAR SymbolW[] = {'S','y','m','b','o','l','\0'};
static const WCHAR *default_serif_list[] =
{
times_new_roman,
liberation_serif,
bitstream_vera_serif,
NULL
};
static const WCHAR *default_fixed_list[] =
{
courier_new,
liberation_mono,
bitstream_vera_sans_mono,
NULL
};
static const WCHAR *default_sans_list[] =
{
arial,
liberation_sans,
bitstream_vera_sans,
NULL
};
static const WCHAR *default_serif = times_new_roman;
static const WCHAR *default_fixed = courier_new;
static const WCHAR *default_sans = arial;
/* Registry font cache key and value names */ /* Registry font cache key and value names */
static const WCHAR wine_fonts_key[] = {'S','o','f','t','w','a','r','e','\\','W','i','n','e','\\', static const WCHAR wine_fonts_key[] = {'S','o','f','t','w','a','r','e','\\','W','i','n','e','\\',
'F','o','n','t','s',0}; 'F','o','n','t','s',0};
@ -2205,41 +2167,6 @@ static void init_font_list(void)
#endif #endif
} }
static BOOL move_to_front(const WCHAR *name)
{
Family *family, *cursor2;
LIST_FOR_EACH_ENTRY_SAFE(family, cursor2, &font_list, Family, entry)
{
if (!strncmpiW( family->family_name, name, LF_FACESIZE - 1 ))
{
list_remove(&family->entry);
list_add_head(&font_list, &family->entry);
return TRUE;
}
}
return FALSE;
}
static const WCHAR *set_default(const WCHAR **name_list)
{
const WCHAR **entry = name_list;
while (*entry)
{
if (move_to_front(*entry)) return *entry;
entry++;
}
return *name_list;
}
static void reorder_font_list(void)
{
default_serif = set_default( default_serif_list );
default_fixed = set_default( default_fixed_list );
default_sans = set_default( default_sans_list );
}
/************************************************************* /*************************************************************
* WineEngInit * WineEngInit
* *
@ -2272,8 +2199,6 @@ BOOL WineEngInit( const struct font_backend_funcs **funcs )
else else
load_font_list_from_cache(hkey_font_cache); load_font_list_from_cache(hkey_font_cache);
reorder_font_list();
if(disposition == REG_CREATED_NEW_KEY) if(disposition == REG_CREATED_NEW_KEY)
update_reg_entries(); update_reg_entries();

View File

@ -479,6 +479,9 @@ extern struct gdi_font *create_gdi_font( const struct gdi_font_face *face, const
const LOGFONTW *lf ) DECLSPEC_HIDDEN; const LOGFONTW *lf ) DECLSPEC_HIDDEN;
extern void *get_GSUB_vert_feature( struct gdi_font *font ) DECLSPEC_HIDDEN; extern void *get_GSUB_vert_feature( struct gdi_font *font ) DECLSPEC_HIDDEN;
extern void font_init(void) DECLSPEC_HIDDEN; extern void font_init(void) DECLSPEC_HIDDEN;
extern const WCHAR *default_serif DECLSPEC_HIDDEN;
extern const WCHAR *default_fixed DECLSPEC_HIDDEN;
extern const WCHAR *default_sans DECLSPEC_HIDDEN;
/* freetype.c */ /* freetype.c */