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
f6d9908e
Commit
f6d9908e
authored
Oct 26, 2020
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gdi32: Move the AddFontMemResourceEx() implementation out of freetype.c.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
047bf252
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
33 deletions
+30
-33
font.c
dlls/gdi32/font.c
+20
-6
freetype.c
dlls/gdi32/freetype.c
+9
-26
gdi_private.h
dlls/gdi32/gdi_private.h
+1
-1
No files found.
dlls/gdi32/font.c
View file @
f6d9908e
...
...
@@ -5429,22 +5429,36 @@ BOOL WINAPI RemoveFontResourceW( LPCWSTR str )
/***********************************************************************
* AddFontMemResourceEx (GDI32.@)
*/
HANDLE
WINAPI
AddFontMemResourceEx
(
PVOID
p
bFont
,
DWORD
cbFont
,
PVOID
pdv
,
DWORD
*
pcFonts
)
HANDLE
WINAPI
AddFontMemResourceEx
(
PVOID
p
tr
,
DWORD
size
,
PVOID
pdv
,
DWORD
*
pcFonts
)
{
HANDLE
ret
;
DWORD
num_fonts
;
void
*
copy
;
if
(
!
p
bFont
||
!
cbFont
||
!
pcFonts
)
if
(
!
p
tr
||
!
size
||
!
pcFonts
)
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
NULL
;
}
if
(
!
font_funcs
)
return
NULL
;
if
(
!
(
copy
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
)))
return
NULL
;
memcpy
(
copy
,
ptr
,
size
);
EnterCriticalSection
(
&
font_cs
);
ret
=
font_funcs
->
pAddFontMemResourceEx
(
pbFont
,
cbFont
,
pdv
,
&
num_fonts
);
num_fonts
=
font_funcs
->
add_mem_font
(
copy
,
size
,
ADDFONT_ALLOW_BITMAP
|
ADDFONT_ADD_RESOURCE
);
LeaveCriticalSection
(
&
font_cs
);
if
(
ret
)
if
(
!
num_fonts
)
{
HeapFree
(
GetProcessHeap
(),
0
,
copy
);
return
NULL
;
}
/* FIXME: is the handle only for use in RemoveFontMemResourceEx or should it be a true handle?
* For now return something unique but quite random
*/
ret
=
(
HANDLE
)((
INT_PTR
)
copy
^
0x87654321
);
__TRY
{
*
pcFonts
=
num_fonts
;
...
...
@@ -5452,11 +5466,11 @@ HANDLE WINAPI AddFontMemResourceEx( PVOID pbFont, DWORD cbFont, PVOID pdv, DWORD
__EXCEPT_PAGE_FAULT
{
WARN
(
"page fault while writing to *pcFonts (%p)
\n
"
,
pcFonts
);
RemoveFontMemResourceEx
(
ret
);
RemoveFontMemResourceEx
(
ret
);
ret
=
0
;
}
__ENDTRY
}
TRACE
(
"Returning handle %p
\n
"
,
ret
);
return
ret
;
}
...
...
dlls/gdi32/freetype.c
View file @
f6d9908e
...
...
@@ -2108,6 +2108,14 @@ static INT CDECL freetype_add_font( const WCHAR *file, DWORD flags )
}
/*************************************************************
* freetype_add_mem_font
*/
static
INT
CDECL
freetype_add_mem_font
(
void
*
ptr
,
SIZE_T
size
,
DWORD
flags
)
{
return
AddFontToList
(
NULL
,
NULL
,
ptr
,
size
,
flags
);
}
/*************************************************************
* freetype_remove_font
*/
static
INT
CDECL
freetype_remove_font
(
const
WCHAR
*
file
,
DWORD
flags
)
...
...
@@ -3049,31 +3057,6 @@ static void delete_external_font_keys(void)
if
(
winnt_key
)
RegCloseKey
(
winnt_key
);
}
/*************************************************************
* freetype_AddFontMemResourceEx
*
*/
static
HANDLE
CDECL
freetype_AddFontMemResourceEx
(
PVOID
pbFont
,
DWORD
cbFont
,
PVOID
pdv
,
DWORD
*
pcFonts
)
{
PVOID
pFontCopy
=
HeapAlloc
(
GetProcessHeap
(),
0
,
cbFont
);
TRACE
(
"Copying %d bytes of data from %p to %p
\n
"
,
cbFont
,
pbFont
,
pFontCopy
);
memcpy
(
pFontCopy
,
pbFont
,
cbFont
);
*
pcFonts
=
AddFontToList
(
NULL
,
NULL
,
pFontCopy
,
cbFont
,
ADDFONT_ALLOW_BITMAP
|
ADDFONT_ADD_RESOURCE
);
if
(
*
pcFonts
==
0
)
{
TRACE
(
"AddFontToList failed
\n
"
);
HeapFree
(
GetProcessHeap
(),
0
,
pFontCopy
);
return
0
;
}
/* FIXME: is the handle only for use in RemoveFontMemResourceEx or should it be a true handle?
* For now return something unique but quite random
*/
TRACE
(
"Returning handle %lx
\n
"
,
((
INT_PTR
)
pFontCopy
)
^
0x87654321
);
return
(
HANDLE
)(((
INT_PTR
)
pFontCopy
)
^
0x87654321
);
}
static
WCHAR
*
get_ttf_file_name
(
LPCWSTR
font_file
,
LPCWSTR
font_path
)
{
WCHAR
*
fullname
;
...
...
@@ -7477,9 +7460,9 @@ static const struct font_backend_funcs font_funcs =
freetype_GetCharWidthInfo
,
freetype_GetFontUnicodeRanges
,
freetype_SelectFont
,
freetype_AddFontMemResourceEx
,
freetype_CreateScalableFontResource
,
freetype_add_font
,
freetype_add_mem_font
,
freetype_remove_font
,
freetype_alloc_font
,
freetype_get_font_data
,
...
...
dlls/gdi32/gdi_private.h
View file @
f6d9908e
...
...
@@ -370,10 +370,10 @@ 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
);
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
);
INT
(
CDECL
*
add_mem_font
)(
void
*
ptr
,
SIZE_T
size
,
DWORD
flags
);
BOOL
(
CDECL
*
remove_font
)(
const
WCHAR
*
file
,
DWORD
flags
);
BOOL
(
CDECL
*
alloc_font
)(
struct
gdi_font
*
font
);
...
...
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