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
89561b92
Commit
89561b92
authored
Oct 07, 2012
by
Nikolay Sivov
Committed by
Alexandre Julliard
Oct 08, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dwrite: Store font family name in IDWriteFontFamily implementation.
parent
096426f1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
74 additions
and
4 deletions
+74
-4
dwrite_private.h
dlls/dwrite/dwrite_private.h
+17
-0
font.c
dlls/dwrite/font.c
+32
-2
font.c
dlls/dwrite/tests/font.c
+25
-2
No files found.
dlls/dwrite/dwrite_private.h
View file @
89561b92
...
...
@@ -16,6 +16,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "wine/unicode.h"
static
inline
void
*
heap_alloc
(
size_t
len
)
{
return
HeapAlloc
(
GetProcessHeap
(),
0
,
len
);
...
...
@@ -26,6 +28,21 @@ static inline BOOL heap_free(void *mem)
return
HeapFree
(
GetProcessHeap
(),
0
,
mem
);
}
static
inline
LPWSTR
heap_strdupW
(
LPCWSTR
str
)
{
LPWSTR
ret
=
NULL
;
if
(
str
)
{
DWORD
size
;
size
=
(
strlenW
(
str
)
+
1
)
*
sizeof
(
WCHAR
);
ret
=
heap_alloc
(
size
);
memcpy
(
ret
,
str
,
size
);
}
return
ret
;
}
extern
HRESULT
create_font_from_logfont
(
const
LOGFONTW
*
,
IDWriteFont
**
)
DECLSPEC_HIDDEN
;
extern
HRESULT
create_textlayout
(
IDWriteTextLayout
**
)
DECLSPEC_HIDDEN
;
extern
HRESULT
create_gdiinterop
(
IDWriteGdiInterop
**
)
DECLSPEC_HIDDEN
;
dlls/dwrite/font.c
View file @
89561b92
...
...
@@ -30,6 +30,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(dwrite);
struct
dwrite_fontfamily
{
IDWriteFontFamily
IDWriteFontFamily_iface
;
LONG
ref
;
WCHAR
*
familyname
;
};
struct
dwrite_font
{
...
...
@@ -222,7 +224,10 @@ static ULONG WINAPI dwritefontfamily_Release(IDWriteFontFamily *iface)
TRACE
(
"(%p)->(%d)
\n
"
,
This
,
ref
);
if
(
!
ref
)
{
heap_free
(
This
->
familyname
);
heap_free
(
This
);
}
return
S_OK
;
}
...
...
@@ -283,7 +288,7 @@ static const IDWriteFontFamilyVtbl fontfamilyvtbl = {
dwritefontfamily_GetMatchingFonts
};
static
HRESULT
create_fontfamily
(
IDWriteFontFamily
**
family
)
static
HRESULT
create_fontfamily
(
const
WCHAR
*
familyname
,
IDWriteFontFamily
**
family
)
{
struct
dwrite_fontfamily
*
This
;
...
...
@@ -294,6 +299,7 @@ static HRESULT create_fontfamily(IDWriteFontFamily **family)
This
->
IDWriteFontFamily_iface
.
lpVtbl
=
&
fontfamilyvtbl
;
This
->
ref
=
1
;
This
->
familyname
=
heap_strdupW
(
familyname
);
*
family
=
&
This
->
IDWriteFontFamily_iface
;
...
...
@@ -302,13 +308,37 @@ static HRESULT create_fontfamily(IDWriteFontFamily **family)
HRESULT
create_font_from_logfont
(
const
LOGFONTW
*
logfont
,
IDWriteFont
**
font
)
{
const
WCHAR
*
facename
,
*
familyname
;
struct
dwrite_font
*
This
;
IDWriteFontFamily
*
family
;
OUTLINETEXTMETRICW
*
otm
;
HRESULT
hr
;
HFONT
hfont
;
HDC
hdc
;
int
ret
;
*
font
=
NULL
;
hr
=
create_fontfamily
(
&
family
);
hfont
=
CreateFontIndirectW
(
logfont
);
if
(
!
hfont
)
return
DWRITE_E_NOFONT
;
hdc
=
CreateCompatibleDC
(
0
);
SelectObject
(
hdc
,
hfont
);
ret
=
GetOutlineTextMetricsW
(
hdc
,
0
,
NULL
);
otm
=
heap_alloc
(
ret
);
otm
->
otmSize
=
ret
;
ret
=
GetOutlineTextMetricsW
(
hdc
,
otm
->
otmSize
,
otm
);
DeleteDC
(
hdc
);
DeleteObject
(
hfont
);
facename
=
(
WCHAR
*
)((
char
*
)
otm
+
(
ptrdiff_t
)
otm
->
otmpFaceName
);
familyname
=
(
WCHAR
*
)((
char
*
)
otm
+
(
ptrdiff_t
)
otm
->
otmpFamilyName
);
TRACE
(
"facename=%s, familyname=%s
\n
"
,
debugstr_w
(
facename
),
debugstr_w
(
familyname
));
hr
=
create_fontfamily
(
familyname
,
&
family
);
heap_free
(
otm
);
if
(
hr
!=
S_OK
)
return
hr
;
This
=
heap_alloc
(
sizeof
(
struct
dwrite_font
));
...
...
dlls/dwrite/tests/font.c
View file @
89561b92
...
...
@@ -43,6 +43,7 @@ static IDWriteFactory *factory;
static
void
test_CreateFontFromLOGFONT
(
void
)
{
static
const
WCHAR
arialW
[]
=
{
'A'
,
'r'
,
'i'
,
'a'
,
'l'
,
0
};
static
const
WCHAR
arialspW
[]
=
{
'A'
,
'r'
,
'i'
,
'a'
,
'l'
,
' '
,
0
};
static
const
WCHAR
blahW
[]
=
{
'B'
,
'l'
,
'a'
,
'h'
,
'!'
,
0
};
IDWriteGdiInterop
*
interop
;
DWRITE_FONT_WEIGHT
weight
;
...
...
@@ -143,18 +144,40 @@ todo_wine
logfont
.
lfWeight
=
FW_NORMAL
;
lstrcpyW
(
logfont
.
lfFaceName
,
blahW
);
font
=
(
void
*
)
0xdeadbeef
;
hr
=
IDWriteGdiInterop_CreateFontFromLOGFONT
(
interop
,
&
logfont
,
&
font
);
todo_wine
todo_wine
{
EXPECT_HR
(
hr
,
DWRITE_E_NOFONT
);
ok
(
font
==
NULL
,
"got %p
\n
"
,
font
);
if
(
font
)
IDWriteFont_Release
(
font
);
}
memset
(
&
logfont
,
0
,
sizeof
(
logfont
));
logfont
.
lfHeight
=
12
;
logfont
.
lfWidth
=
12
;
logfont
.
lfWeight
=
FW_NORMAL
;
lstrcpyW
(
logfont
.
lfFaceName
,
arialspW
);
font
=
(
void
*
)
0xdeadbeef
;
hr
=
IDWriteGdiInterop_CreateFontFromLOGFONT
(
interop
,
&
logfont
,
&
font
);
todo_wine
todo_wine
{
EXPECT_HR
(
hr
,
DWRITE_E_NOFONT
);
ok
(
font
==
NULL
,
"got %p
\n
"
,
font
);
if
(
font
)
IDWriteFont_Release
(
font
);
}
memset
(
&
logfont
,
0
,
sizeof
(
logfont
));
logfont
.
lfHeight
=
12
;
logfont
.
lfWidth
=
12
;
logfont
.
lfWeight
=
FW_NORMAL
;
font
=
(
void
*
)
0xdeadbeef
;
hr
=
IDWriteGdiInterop_CreateFontFromLOGFONT
(
interop
,
&
logfont
,
&
font
);
todo_wine
{
EXPECT_HR
(
hr
,
DWRITE_E_NOFONT
);
ok
(
font
==
NULL
,
"got %p
\n
"
,
font
);
if
(
font
)
IDWriteFont_Release
(
font
);
}
IDWriteGdiInterop_Release
(
interop
);
}
...
...
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