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

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2020-10-30 14:22:51 +01:00
parent 7e51cc8308
commit 6a1cdd98fa
3 changed files with 70 additions and 66 deletions

View File

@ -443,7 +443,7 @@ const WCHAR *get_gdi_font_subst( const WCHAR *from_name, int from_charset, int *
return NULL;
}
BOOL add_gdi_font_subst( const WCHAR *from_name, int from_charset, const WCHAR *to_name, int to_charset )
static BOOL add_gdi_font_subst( const WCHAR *from_name, int from_charset, const WCHAR *to_name, int to_charset )
{
struct gdi_font_subst *subst;
int len = strlenW( from_name ) + strlenW( to_name ) + 2;
@ -500,6 +500,57 @@ void load_gdi_font_subst(void)
RegCloseKey( hkey );
}
/* font families */
struct list font_list = LIST_INIT(font_list);
struct gdi_font_family *create_family( const WCHAR *name, const WCHAR *second_name )
{
struct gdi_font_family *family = HeapAlloc( GetProcessHeap(), 0, sizeof(*family) );
family->refcount = 1;
lstrcpynW( family->family_name, name, LF_FACESIZE );
if (second_name && second_name[0])
{
lstrcpynW( family->second_name, second_name, LF_FACESIZE );
add_gdi_font_subst( second_name, -1, name, -1 );
}
else family->second_name[0] = 0;
list_init( &family->faces );
family->replacement = &family->faces;
list_add_tail( &font_list, &family->entry );
return family;
}
void release_family( struct gdi_font_family *family )
{
if (--family->refcount) return;
assert( list_empty( &family->faces ));
list_remove( &family->entry );
HeapFree( GetProcessHeap(), 0, family );
}
struct gdi_font_family *find_family_from_name( const WCHAR *name )
{
struct gdi_font_family *family;
LIST_FOR_EACH_ENTRY( family, &font_list, struct gdi_font_family, entry )
if (!strncmpiW( family->family_name, name, LF_FACESIZE - 1 )) return family;
return NULL;
}
struct gdi_font_family *find_family_from_any_name( const WCHAR *name )
{
struct gdi_font_family *family;
LIST_FOR_EACH_ENTRY( family, &font_list, struct gdi_font_family, entry )
{
if (!strncmpiW( family->family_name, name, LF_FACESIZE - 1 )) return family;
if (!strncmpiW( family->second_name, name, LF_FACESIZE - 1 )) return family;
}
return NULL;
}
/* realized font objects */
#define FIRST_FONT_HANDLE 1

View File

@ -265,21 +265,14 @@ typedef struct tagFace {
BOOL scalable;
Bitmap_Size size; /* set if face is a bitmap */
DWORD flags; /* ADDFONT flags */
struct tagFamily *family;
struct gdi_font_family *family;
/* Cached data for Enum */
struct enum_data *cached_enum_data;
} Face;
#define FS_DBCS_MASK (FS_JISJAPAN|FS_CHINESESIMP|FS_WANSUNG|FS_CHINESETRAD|FS_JOHAB)
typedef struct tagFamily {
struct list entry;
unsigned int refcount;
WCHAR family_name[LF_FACESIZE];
WCHAR second_name[LF_FACESIZE];
struct list faces;
struct list *replacement;
} Family;
typedef struct gdi_font_family Family;
typedef struct {
struct list entry;
@ -317,8 +310,6 @@ struct enum_charset_list {
static struct list system_links = LIST_INIT(system_links);
static struct list font_list = LIST_INIT(font_list);
static const struct font_backend_funcs font_funcs;
static const WCHAR win9x_font_reg_key[] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
@ -745,29 +736,6 @@ static Face *find_face_from_filename(const WCHAR *file_name, const WCHAR *face_n
return NULL;
}
static Family *find_family_from_name(const WCHAR *name)
{
Family *family;
LIST_FOR_EACH_ENTRY(family, &font_list, Family, entry)
if (!strncmpiW( family->family_name, name, LF_FACESIZE - 1 )) return family;
return NULL;
}
static Family *find_family_from_any_name(const WCHAR *name)
{
Family *family;
LIST_FOR_EACH_ENTRY(family, &font_list, Family, entry)
{
if (!strncmpiW( family->family_name, name, LF_FACESIZE - 1 )) return family;
if (!strncmpiW( family->second_name, name, LF_FACESIZE - 1 )) return family;
}
return NULL;
}
static LPWSTR strdupW(LPCWSTR p)
{
LPWSTR ret;
@ -1076,14 +1044,6 @@ static inline BOOL faces_equal( const Face *f1, const Face *f2 )
return !memcmp( &f1->fs, &f2->fs, sizeof(f1->fs) );
}
static void release_family( Family *family )
{
if (--family->refcount) return;
assert( list_empty( &family->faces ));
list_remove( &family->entry );
HeapFree( GetProcessHeap(), 0, family );
}
static void release_face( Face *face )
{
if (--face->refcount) return;
@ -1168,28 +1128,6 @@ static BOOL insert_face_in_family_list( Face *face, Family *family )
return TRUE;
}
/****************************************************************
* NB This function stores the ptrs to the strings to save copying.
* Don't free them after calling.
*/
static Family *create_family( WCHAR *family_name, WCHAR *second_name )
{
Family * const family = HeapAlloc( GetProcessHeap(), 0, sizeof(*family) );
family->refcount = 1;
lstrcpynW( family->family_name, family_name, LF_FACESIZE );
if (second_name)
{
lstrcpynW( family->second_name, second_name, LF_FACESIZE );
add_gdi_font_subst( second_name, -1, family_name, -1 );
}
else family->second_name[0] = 0;
list_init( &family->faces );
family->replacement = &family->faces;
list_add_tail( &font_list, &family->entry );
return family;
}
struct cached_face
{
DWORD index;

View File

@ -305,6 +305,16 @@ typedef struct { FLOAT eM11, eM12, eM21, eM22; } FMAT2;
struct glyph_metrics;
struct gdi_font_family
{
struct list entry;
unsigned int refcount;
WCHAR family_name[LF_FACESIZE];
WCHAR second_name[LF_FACESIZE];
struct list faces;
struct list *replacement;
};
struct gdi_font
{
struct list entry;
@ -396,9 +406,14 @@ extern void load_file_system_fonts(void) DECLSPEC_HIDDEN;
extern void load_registry_fonts(void) DECLSPEC_HIDDEN;
extern const WCHAR *get_gdi_font_subst( const WCHAR *from_name, int from_charset, int *to_charset ) DECLSPEC_HIDDEN;
extern BOOL add_gdi_font_subst( const WCHAR *from_name, int from_charset, const WCHAR *to_name, int to_charset ) DECLSPEC_HIDDEN;
extern void load_gdi_font_subst(void) DECLSPEC_HIDDEN;
extern struct list font_list DECLSPEC_HIDDEN;
extern struct gdi_font_family *create_family( const WCHAR *name, const WCHAR *second_name ) DECLSPEC_HIDDEN;
extern void release_family( struct gdi_font_family *family ) DECLSPEC_HIDDEN;
extern struct gdi_font_family *find_family_from_name( const WCHAR *name ) DECLSPEC_HIDDEN;
extern struct gdi_font_family *find_family_from_any_name( const WCHAR *name ) DECLSPEC_HIDDEN;
extern struct gdi_font *alloc_gdi_font( const WCHAR *file, void *data_ptr, SIZE_T data_size ) DECLSPEC_HIDDEN;
extern void free_gdi_font( struct gdi_font *font ) DECLSPEC_HIDDEN;
extern void cache_gdi_font( struct gdi_font *font ) DECLSPEC_HIDDEN;