Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
047bf252
Commit
047bf252
authored
Oct 26, 2020
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gdi32: Move the Add/RemoveFontResource() implementation out of freetype.c.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
f3a75923
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
114 additions
and
93 deletions
+114
-93
font.c
dlls/gdi32/font.c
+90
-20
freetype.c
dlls/gdi32/freetype.c
+15
-71
gdi_private.h
dlls/gdi32/gdi_private.h
+9
-2
No files found.
dlls/gdi32/font.c
View file @
047bf252
...
...
@@ -5293,21 +5293,99 @@ fail:
return
name
;
}
static
int
add_system_font_resource
(
const
WCHAR
*
file
,
DWORD
flags
)
{
WCHAR
path
[
MAX_PATH
];
int
ret
;
/* try in %WINDIR%/fonts, needed for Fotobuch Designer */
get_fonts_win_dir_path
(
file
,
path
);
EnterCriticalSection
(
&
font_cs
);
ret
=
font_funcs
->
add_font
(
path
,
flags
);
LeaveCriticalSection
(
&
font_cs
);
/* try in datadir/fonts (or builddir/fonts), needed for Magic the Gathering Online */
if
(
!
ret
)
{
get_fonts_data_dir_path
(
file
,
path
);
EnterCriticalSection
(
&
font_cs
);
ret
=
font_funcs
->
add_font
(
path
,
flags
);
LeaveCriticalSection
(
&
font_cs
);
}
return
ret
;
}
static
BOOL
remove_system_font_resource
(
LPCWSTR
file
,
DWORD
flags
)
{
WCHAR
path
[
MAX_PATH
];
int
ret
;
get_fonts_win_dir_path
(
file
,
path
);
EnterCriticalSection
(
&
font_cs
);
ret
=
font_funcs
->
remove_font
(
path
,
flags
);
LeaveCriticalSection
(
&
font_cs
);
if
(
!
ret
)
{
get_fonts_data_dir_path
(
file
,
path
);
EnterCriticalSection
(
&
font_cs
);
ret
=
font_funcs
->
remove_font
(
path
,
flags
);
LeaveCriticalSection
(
&
font_cs
);
}
return
ret
;
}
static
int
add_font_resource
(
LPCWSTR
file
,
DWORD
flags
)
{
WCHAR
path
[
MAX_PATH
];
int
ret
=
0
;
if
(
GetFullPathNameW
(
file
,
MAX_PATH
,
path
,
NULL
))
{
DWORD
addfont_flags
=
ADDFONT_ALLOW_BITMAP
|
ADDFONT_ADD_RESOURCE
;
if
(
!
(
flags
&
FR_PRIVATE
))
addfont_flags
|=
ADDFONT_ADD_TO_CACHE
;
EnterCriticalSection
(
&
font_cs
);
ret
=
font_funcs
->
add_font
(
path
,
addfont_flags
);
LeaveCriticalSection
(
&
font_cs
);
}
if
(
!
ret
&&
!
strchrW
(
file
,
'\\'
))
ret
=
add_system_font_resource
(
file
,
ADDFONT_ALLOW_BITMAP
|
ADDFONT_ADD_RESOURCE
);
return
ret
;
}
static
BOOL
remove_font_resource
(
LPCWSTR
file
,
DWORD
flags
)
{
WCHAR
path
[
MAX_PATH
];
BOOL
ret
=
FALSE
;
if
(
GetFullPathNameW
(
file
,
MAX_PATH
,
path
,
NULL
))
{
DWORD
addfont_flags
=
ADDFONT_ALLOW_BITMAP
|
ADDFONT_ADD_RESOURCE
;
if
(
!
(
flags
&
FR_PRIVATE
))
addfont_flags
|=
ADDFONT_ADD_TO_CACHE
;
EnterCriticalSection
(
&
font_cs
);
ret
=
font_funcs
->
remove_font
(
path
,
addfont_flags
);
LeaveCriticalSection
(
&
font_cs
);
}
if
(
!
ret
&&
!
strchrW
(
file
,
'\\'
))
ret
=
remove_system_font_resource
(
file
,
ADDFONT_ALLOW_BITMAP
|
ADDFONT_ADD_RESOURCE
);
return
ret
;
}
/***********************************************************************
* AddFontResourceExW (GDI32.@)
*/
INT
WINAPI
AddFontResourceExW
(
LPCWSTR
str
,
DWORD
fl
,
PVOID
pdv
)
INT
WINAPI
AddFontResourceExW
(
LPCWSTR
str
,
DWORD
fl
ags
,
PVOID
pdv
)
{
int
ret
;
WCHAR
*
filename
;
BOOL
hidden
;
if
(
!
font_funcs
)
return
1
;
EnterCriticalSection
(
&
font_cs
);
ret
=
font_funcs
->
pAddFontResourceEx
(
str
,
fl
,
pdv
);
LeaveCriticalSection
(
&
font_cs
);
if
(
!
ret
)
if
(
!
(
ret
=
add_font_resource
(
str
,
flags
)))
{
/* FreeType <2.3.5 has problems reading resources wrapped in PE files. */
HMODULE
hModule
=
LoadLibraryExW
(
str
,
NULL
,
LOAD_LIBRARY_AS_DATAFILE
);
...
...
@@ -5324,10 +5402,8 @@ INT WINAPI AddFontResourceExW( LPCWSTR str, DWORD fl, PVOID pdv )
}
else
if
((
filename
=
get_scalable_filename
(
str
,
&
hidden
))
!=
NULL
)
{
if
(
hidden
)
fl
|=
FR_PRIVATE
|
FR_NOT_ENUM
;
EnterCriticalSection
(
&
font_cs
);
ret
=
font_funcs
->
pAddFontResourceEx
(
filename
,
fl
,
pdv
);
LeaveCriticalSection
(
&
font_cs
);
if
(
hidden
)
flags
|=
FR_PRIVATE
|
FR_NOT_ENUM
;
ret
=
add_font_resource
(
filename
,
flags
);
HeapFree
(
GetProcessHeap
(),
0
,
filename
);
}
}
...
...
@@ -5411,7 +5487,7 @@ BOOL WINAPI RemoveFontResourceExA( LPCSTR str, DWORD fl, PVOID pdv )
/***********************************************************************
* RemoveFontResourceExW (GDI32.@)
*/
BOOL
WINAPI
RemoveFontResourceExW
(
LPCWSTR
str
,
DWORD
fl
,
PVOID
pdv
)
BOOL
WINAPI
RemoveFontResourceExW
(
LPCWSTR
str
,
DWORD
fl
ags
,
PVOID
pdv
)
{
int
ret
;
WCHAR
*
filename
;
...
...
@@ -5419,11 +5495,7 @@ BOOL WINAPI RemoveFontResourceExW( LPCWSTR str, DWORD fl, PVOID pdv )
if
(
!
font_funcs
)
return
TRUE
;
EnterCriticalSection
(
&
font_cs
);
ret
=
font_funcs
->
pRemoveFontResourceEx
(
str
,
fl
,
pdv
);
LeaveCriticalSection
(
&
font_cs
);
if
(
!
ret
)
if
(
!
(
ret
=
remove_font_resource
(
str
,
flags
)))
{
/* FreeType <2.3.5 has problems reading resources wrapped in PE files. */
HMODULE
hModule
=
LoadLibraryExW
(
str
,
NULL
,
LOAD_LIBRARY_AS_DATAFILE
);
...
...
@@ -5434,10 +5506,8 @@ BOOL WINAPI RemoveFontResourceExW( LPCWSTR str, DWORD fl, PVOID pdv )
}
else
if
((
filename
=
get_scalable_filename
(
str
,
&
hidden
))
!=
NULL
)
{
if
(
hidden
)
fl
|=
FR_PRIVATE
|
FR_NOT_ENUM
;
EnterCriticalSection
(
&
font_cs
);
ret
=
font_funcs
->
pRemoveFontResourceEx
(
filename
,
fl
,
pdv
);
LeaveCriticalSection
(
&
font_cs
);
if
(
hidden
)
flags
|=
FR_PRIVATE
|
FR_NOT_ENUM
;
ret
=
remove_font_resource
(
filename
,
flags
);
HeapFree
(
GetProcessHeap
(),
0
,
filename
);
}
}
...
...
dlls/gdi32/freetype.c
View file @
047bf252
...
...
@@ -272,13 +272,6 @@ typedef struct tagFace {
#define FS_DBCS_MASK (FS_JISJAPAN|FS_CHINESESIMP|FS_WANSUNG|FS_CHINESETRAD|FS_JOHAB)
#define ADDFONT_EXTERNAL_FONT 0x01
#define ADDFONT_ALLOW_BITMAP 0x02
#define ADDFONT_ADD_TO_CACHE 0x04
#define ADDFONT_ADD_RESOURCE 0x08
/* added through AddFontResource */
#define ADDFONT_VERTICAL_FONT 0x10
#define ADDFONT_AA_FLAGS(flags) ((flags) << 16)
typedef
struct
tagFamily
{
struct
list
entry
;
unsigned
int
refcount
;
...
...
@@ -2098,7 +2091,10 @@ static INT AddFontToList(const WCHAR *dos_name, const char *unix_name, void *fon
return
ret
;
}
static
int
add_font_resource
(
const
WCHAR
*
file
,
DWORD
flags
)
/*************************************************************
* freetype_add_font
*/
static
INT
CDECL
freetype_add_font
(
const
WCHAR
*
file
,
DWORD
flags
)
{
int
ret
=
0
;
char
*
unixname
=
wine_get_unix_file_name
(
file
);
...
...
@@ -2111,7 +2107,10 @@ static int add_font_resource( const WCHAR *file, DWORD flags )
return
ret
;
}
static
int
remove_font_resource
(
const
WCHAR
*
file
,
DWORD
flags
)
/*************************************************************
* freetype_remove_font
*/
static
INT
CDECL
freetype_remove_font
(
const
WCHAR
*
file
,
DWORD
flags
)
{
Family
*
family
,
*
family_next
;
Face
*
face
,
*
face_next
;
...
...
@@ -2867,10 +2866,10 @@ static void load_system_fonts(void)
if
(
RegQueryValueExW
(
hkey
,
*
value
,
0
,
&
type
,
(
void
*
)
data
,
&
dlen
)
==
ERROR_SUCCESS
&&
type
==
REG_SZ
)
{
get_fonts_win_dir_path
(
data
,
pathW
);
if
(
!
add_font_resource
(
pathW
,
ADDFONT_ALLOW_BITMAP
|
ADDFONT_ADD_TO_CACHE
))
if
(
!
freetype_add_font
(
pathW
,
ADDFONT_ALLOW_BITMAP
|
ADDFONT_ADD_TO_CACHE
))
{
get_fonts_data_dir_path
(
data
,
pathW
);
add_font_resource
(
pathW
,
ADDFONT_ALLOW_BITMAP
|
ADDFONT_ADD_TO_CACHE
);
freetype_add_font
(
pathW
,
ADDFONT_ALLOW_BITMAP
|
ADDFONT_ADD_TO_CACHE
);
}
}
}
...
...
@@ -3051,34 +3050,6 @@ static void delete_external_font_keys(void)
}
/*************************************************************
* freetype_AddFontResourceEx
*
*/
static
INT
CDECL
freetype_AddFontResourceEx
(
LPCWSTR
file
,
DWORD
flags
,
PVOID
pdv
)
{
WCHAR
path
[
MAX_PATH
];
INT
ret
=
0
;
DWORD
addfont_flags
=
ADDFONT_ALLOW_BITMAP
|
ADDFONT_ADD_RESOURCE
;
if
(
!
(
flags
&
FR_PRIVATE
))
addfont_flags
|=
ADDFONT_ADD_TO_CACHE
;
if
(
GetFullPathNameW
(
file
,
MAX_PATH
,
path
,
NULL
))
ret
=
add_font_resource
(
path
,
addfont_flags
);
if
(
!
ret
&&
!
strchrW
(
file
,
'\\'
))
{
/* Try in %WINDIR%/fonts, needed for Fotobuch Designer */
get_fonts_win_dir_path
(
file
,
path
);
ret
=
add_font_resource
(
path
,
ADDFONT_ALLOW_BITMAP
|
ADDFONT_ADD_RESOURCE
);
/* Try in datadir/fonts (or builddir/fonts), needed for Magic the Gathering Online */
if
(
!
ret
)
{
get_fonts_data_dir_path
(
file
,
path
);
ret
=
add_font_resource
(
path
,
ADDFONT_ALLOW_BITMAP
|
ADDFONT_ADD_RESOURCE
);
}
}
return
ret
;
}
/*************************************************************
* freetype_AddFontMemResourceEx
*
*/
...
...
@@ -3103,33 +3074,6 @@ static HANDLE CDECL freetype_AddFontMemResourceEx(PVOID pbFont, DWORD cbFont, PV
return
(
HANDLE
)(((
INT_PTR
)
pFontCopy
)
^
0x87654321
);
}
/*************************************************************
* freetype_RemoveFontResourceEx
*
*/
static
BOOL
CDECL
freetype_RemoveFontResourceEx
(
LPCWSTR
file
,
DWORD
flags
,
PVOID
pdv
)
{
WCHAR
path
[
MAX_PATH
];
INT
ret
=
0
;
DWORD
addfont_flags
=
ADDFONT_ALLOW_BITMAP
|
ADDFONT_ADD_RESOURCE
;
if
(
!
(
flags
&
FR_PRIVATE
))
addfont_flags
|=
ADDFONT_ADD_TO_CACHE
;
if
(
GetFullPathNameW
(
file
,
MAX_PATH
,
path
,
NULL
))
ret
=
remove_font_resource
(
path
,
addfont_flags
);
if
(
!
ret
&&
!
strchrW
(
file
,
'\\'
))
{
get_fonts_win_dir_path
(
file
,
path
);
ret
=
remove_font_resource
(
path
,
ADDFONT_ALLOW_BITMAP
|
ADDFONT_ADD_RESOURCE
);
if
(
!
ret
)
{
get_fonts_data_dir_path
(
file
,
path
);
ret
=
remove_font_resource
(
path
,
ADDFONT_ALLOW_BITMAP
|
ADDFONT_ADD_RESOURCE
);
}
}
return
ret
;
}
static
WCHAR
*
get_ttf_file_name
(
LPCWSTR
font_file
,
LPCWSTR
font_path
)
{
WCHAR
*
fullname
;
...
...
@@ -3565,17 +3509,17 @@ static void init_font_list(void)
{
if
(
data
[
0
]
&&
(
data
[
1
]
==
':'
))
{
add_font_resource
(
data
,
ADDFONT_ALLOW_BITMAP
|
ADDFONT_ADD_TO_CACHE
);
freetype_add_font
(
data
,
ADDFONT_ALLOW_BITMAP
|
ADDFONT_ADD_TO_CACHE
);
}
else
if
(
dlen
/
2
>=
6
&&
!
strcmpiW
(
data
+
dlen
/
2
-
5
,
dot_fonW
))
{
WCHAR
pathW
[
MAX_PATH
];
get_fonts_win_dir_path
(
data
,
pathW
);
if
(
!
add_font_resource
(
pathW
,
ADDFONT_ALLOW_BITMAP
|
ADDFONT_ADD_TO_CACHE
))
if
(
!
freetype_add_font
(
pathW
,
ADDFONT_ALLOW_BITMAP
|
ADDFONT_ADD_TO_CACHE
))
{
get_fonts_data_dir_path
(
data
,
pathW
);
add_font_resource
(
pathW
,
ADDFONT_ALLOW_BITMAP
|
ADDFONT_ADD_TO_CACHE
);
freetype_add_font
(
pathW
,
ADDFONT_ALLOW_BITMAP
|
ADDFONT_ADD_TO_CACHE
);
}
}
/* reset dlen and vlen */
...
...
@@ -7533,10 +7477,10 @@ static const struct font_backend_funcs font_funcs =
freetype_GetCharWidthInfo
,
freetype_GetFontUnicodeRanges
,
freetype_SelectFont
,
freetype_AddFontResourceEx
,
freetype_RemoveFontResourceEx
,
freetype_AddFontMemResourceEx
,
freetype_CreateScalableFontResource
,
freetype_add_font
,
freetype_remove_font
,
freetype_alloc_font
,
freetype_get_font_data
,
freetype_get_glyph_index
,
...
...
dlls/gdi32/gdi_private.h
View file @
047bf252
...
...
@@ -355,6 +355,13 @@ struct gdi_font
#define MS_TTCF_TAG MS_MAKE_TAG('t', 't', 'c', 'f')
#define MS_VDMX_TAG MS_MAKE_TAG('V', 'D', 'M', 'X')
#define ADDFONT_EXTERNAL_FONT 0x01
#define ADDFONT_ALLOW_BITMAP 0x02
#define ADDFONT_ADD_TO_CACHE 0x04
#define ADDFONT_ADD_RESOURCE 0x08
/* added through AddFontResource */
#define ADDFONT_VERTICAL_FONT 0x10
#define ADDFONT_AA_FLAGS(flags) ((flags) << 16)
struct
font_backend_funcs
{
BOOL
(
CDECL
*
pEnumFonts
)(
LOGFONTW
*
lf
,
FONTENUMPROCW
proc
,
LPARAM
lparam
);
...
...
@@ -363,11 +370,11 @@ struct font_backend_funcs
DWORD
(
CDECL
*
pGetFontUnicodeRanges
)(
struct
gdi_font
*
font
,
GLYPHSET
*
glyphset
);
struct
gdi_font
*
(
CDECL
*
pSelectFont
)(
DC
*
dc
,
HFONT
hfont
,
UINT
*
aa_flags
,
UINT
default_aa_flags
);
INT
(
CDECL
*
pAddFontResourceEx
)(
LPCWSTR
file
,
DWORD
flags
,
PVOID
pdv
);
INT
(
CDECL
*
pRemoveFontResourceEx
)(
LPCWSTR
file
,
DWORD
flags
,
PVOID
pdv
);
HANDLE
(
CDECL
*
pAddFontMemResourceEx
)(
void
*
font
,
DWORD
size
,
PVOID
pdv
,
DWORD
*
count
);
BOOL
(
CDECL
*
pCreateScalableFontResource
)(
DWORD
hidden
,
LPCWSTR
resource
,
LPCWSTR
font_file
,
LPCWSTR
font_path
);
INT
(
CDECL
*
add_font
)(
const
WCHAR
*
file
,
DWORD
flags
);
BOOL
(
CDECL
*
remove_font
)(
const
WCHAR
*
file
,
DWORD
flags
);
BOOL
(
CDECL
*
alloc_font
)(
struct
gdi_font
*
font
);
DWORD
(
CDECL
*
get_font_data
)(
struct
gdi_font
*
gdi_font
,
DWORD
table
,
DWORD
offset
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment