gdi32: Move the remove_font() function out of freetype.c.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
28764bd0c5
commit
6c5dc58a82
|
@ -574,7 +574,7 @@ static struct gdi_font_family *create_family( const WCHAR *name, const WCHAR *se
|
||||||
return family;
|
return family;
|
||||||
}
|
}
|
||||||
|
|
||||||
void release_family( struct gdi_font_family *family )
|
static void release_family( struct gdi_font_family *family )
|
||||||
{
|
{
|
||||||
if (--family->refcount) return;
|
if (--family->refcount) return;
|
||||||
assert( list_empty( &family->faces ));
|
assert( list_empty( &family->faces ));
|
||||||
|
@ -754,7 +754,7 @@ static void reorder_font_list(void)
|
||||||
default_sans = set_default_family( default_sans_list );
|
default_sans = set_default_family( default_sans_list );
|
||||||
}
|
}
|
||||||
|
|
||||||
void release_face( struct gdi_font_face *face )
|
static void release_face( struct gdi_font_face *face )
|
||||||
{
|
{
|
||||||
if (--face->refcount) return;
|
if (--face->refcount) return;
|
||||||
if (face->family)
|
if (face->family)
|
||||||
|
@ -770,6 +770,33 @@ void release_face( struct gdi_font_face *face )
|
||||||
HeapFree( GetProcessHeap(), 0, face );
|
HeapFree( GetProcessHeap(), 0, face );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int remove_font( const WCHAR *file, DWORD flags )
|
||||||
|
{
|
||||||
|
struct gdi_font_family *family, *family_next;
|
||||||
|
struct gdi_font_face *face, *face_next;
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
|
EnterCriticalSection( &font_cs );
|
||||||
|
LIST_FOR_EACH_ENTRY_SAFE( family, family_next, &font_list, struct gdi_font_family, entry )
|
||||||
|
{
|
||||||
|
family->refcount++;
|
||||||
|
LIST_FOR_EACH_ENTRY_SAFE( face, face_next, &family->faces, struct gdi_font_face, entry )
|
||||||
|
{
|
||||||
|
if (!face->file) continue;
|
||||||
|
if (LOWORD(face->flags) != LOWORD(flags)) continue;
|
||||||
|
if (!strcmpiW( face->file, file ))
|
||||||
|
{
|
||||||
|
TRACE( "removing matching face %s refcount %d\n", debugstr_w(face->file), face->refcount );
|
||||||
|
release_face( face );
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
release_family( family );
|
||||||
|
}
|
||||||
|
LeaveCriticalSection( &font_cs );
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
static inline BOOL faces_equal( const struct gdi_font_face *f1, const struct gdi_font_face *f2 )
|
static inline BOOL faces_equal( const struct gdi_font_face *f1, const struct gdi_font_face *f2 )
|
||||||
{
|
{
|
||||||
if (strcmpiW( f1->full_name, f2->full_name )) return FALSE;
|
if (strcmpiW( f1->full_name, f2->full_name )) return FALSE;
|
||||||
|
@ -7351,15 +7378,10 @@ static BOOL remove_system_font_resource( LPCWSTR file, DWORD flags )
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
get_fonts_win_dir_path( file, path );
|
get_fonts_win_dir_path( file, path );
|
||||||
EnterCriticalSection( &font_cs );
|
if (!(ret = remove_font( path, flags )))
|
||||||
ret = font_funcs->remove_font( path, flags );
|
|
||||||
LeaveCriticalSection( &font_cs );
|
|
||||||
if (!ret)
|
|
||||||
{
|
{
|
||||||
get_fonts_data_dir_path( file, path );
|
get_fonts_data_dir_path( file, path );
|
||||||
EnterCriticalSection( &font_cs );
|
ret = remove_font( path, flags );
|
||||||
ret = font_funcs->remove_font( path, flags );
|
|
||||||
LeaveCriticalSection( &font_cs );
|
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -7395,9 +7417,7 @@ static BOOL remove_font_resource( LPCWSTR file, DWORD flags )
|
||||||
DWORD addfont_flags = ADDFONT_ALLOW_BITMAP | ADDFONT_ADD_RESOURCE;
|
DWORD addfont_flags = ADDFONT_ALLOW_BITMAP | ADDFONT_ADD_RESOURCE;
|
||||||
|
|
||||||
if (!(flags & FR_PRIVATE)) addfont_flags |= ADDFONT_ADD_TO_CACHE;
|
if (!(flags & FR_PRIVATE)) addfont_flags |= ADDFONT_ADD_TO_CACHE;
|
||||||
EnterCriticalSection( &font_cs );
|
ret = remove_font( path, addfont_flags );
|
||||||
ret = font_funcs->remove_font( path, addfont_flags );
|
|
||||||
LeaveCriticalSection( &font_cs );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ret && !strchrW( file, '\\' ))
|
if (!ret && !strchrW( file, '\\' ))
|
||||||
|
|
|
@ -1178,34 +1178,6 @@ static INT CDECL freetype_add_mem_font( void *ptr, SIZE_T size, DWORD flags )
|
||||||
return AddFontToList( NULL, NULL, ptr, size, flags );
|
return AddFontToList( NULL, NULL, ptr, size, flags );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************************************************************
|
|
||||||
* freetype_remove_font
|
|
||||||
*/
|
|
||||||
static INT CDECL freetype_remove_font( const WCHAR *file, DWORD flags )
|
|
||||||
{
|
|
||||||
Family *family, *family_next;
|
|
||||||
Face *face, *face_next;
|
|
||||||
int count = 0;
|
|
||||||
|
|
||||||
LIST_FOR_EACH_ENTRY_SAFE( family, family_next, &font_list, Family, entry )
|
|
||||||
{
|
|
||||||
family->refcount++;
|
|
||||||
LIST_FOR_EACH_ENTRY_SAFE( face, face_next, &family->faces, Face, entry )
|
|
||||||
{
|
|
||||||
if (!face->file) continue;
|
|
||||||
if (LOWORD(face->flags) != LOWORD(flags)) continue;
|
|
||||||
if (!strcmpiW( face->file, file ))
|
|
||||||
{
|
|
||||||
TRACE( "removing matching face %s refcount %d\n", debugstr_w(face->file), face->refcount );
|
|
||||||
release_face( face );
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
release_family( family );
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __ANDROID__
|
#ifdef __ANDROID__
|
||||||
static BOOL ReadFontDir(const char *dirname, BOOL external_fonts)
|
static BOOL ReadFontDir(const char *dirname, BOOL external_fonts)
|
||||||
{
|
{
|
||||||
|
@ -4431,7 +4403,6 @@ static const struct font_backend_funcs font_funcs =
|
||||||
freetype_load_fonts,
|
freetype_load_fonts,
|
||||||
freetype_add_font,
|
freetype_add_font,
|
||||||
freetype_add_mem_font,
|
freetype_add_mem_font,
|
||||||
freetype_remove_font,
|
|
||||||
freetype_load_font,
|
freetype_load_font,
|
||||||
freetype_get_font_data,
|
freetype_get_font_data,
|
||||||
freetype_get_aa_flags,
|
freetype_get_aa_flags,
|
||||||
|
|
|
@ -430,7 +430,6 @@ struct font_backend_funcs
|
||||||
void (CDECL *load_fonts)(void);
|
void (CDECL *load_fonts)(void);
|
||||||
INT (CDECL *add_font)( const WCHAR *file, DWORD flags );
|
INT (CDECL *add_font)( const WCHAR *file, DWORD flags );
|
||||||
INT (CDECL *add_mem_font)( void *ptr, SIZE_T size, DWORD flags );
|
INT (CDECL *add_mem_font)( void *ptr, SIZE_T size, DWORD flags );
|
||||||
BOOL (CDECL *remove_font)( const WCHAR *file, DWORD flags );
|
|
||||||
|
|
||||||
BOOL (CDECL *load_font)( struct gdi_font *gdi_font );
|
BOOL (CDECL *load_font)( struct gdi_font *gdi_font );
|
||||||
DWORD (CDECL *get_font_data)( struct gdi_font *gdi_font, DWORD table, DWORD offset,
|
DWORD (CDECL *get_font_data)( struct gdi_font *gdi_font, DWORD table, DWORD offset,
|
||||||
|
@ -452,9 +451,7 @@ struct font_backend_funcs
|
||||||
extern const WCHAR *get_gdi_font_subst( const WCHAR *from_name, int from_charset, int *to_charset ) DECLSPEC_HIDDEN;
|
extern const WCHAR *get_gdi_font_subst( const WCHAR *from_name, int from_charset, int *to_charset ) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
extern struct list font_list DECLSPEC_HIDDEN;
|
extern struct list font_list DECLSPEC_HIDDEN;
|
||||||
extern void release_family( struct gdi_font_family *family ) DECLSPEC_HIDDEN;
|
|
||||||
extern struct gdi_font_family *find_family_from_any_name( const WCHAR *name ) DECLSPEC_HIDDEN;
|
extern struct gdi_font_family *find_family_from_any_name( const WCHAR *name ) DECLSPEC_HIDDEN;
|
||||||
extern void release_face( struct gdi_font_face *face ) DECLSPEC_HIDDEN;
|
|
||||||
extern int add_gdi_face( const WCHAR *family_name, const WCHAR *second_name,
|
extern int add_gdi_face( const WCHAR *family_name, const WCHAR *second_name,
|
||||||
const WCHAR *style, const WCHAR *fullname, const WCHAR *file,
|
const WCHAR *style, const WCHAR *fullname, const WCHAR *file,
|
||||||
void *data_ptr, SIZE_T data_size, UINT index, FONTSIGNATURE fs,
|
void *data_ptr, SIZE_T data_size, UINT index, FONTSIGNATURE fs,
|
||||||
|
|
Loading…
Reference in New Issue