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
debc356a
Commit
debc356a
authored
Aug 25, 2012
by
Nikolay Sivov
Committed by
Alexandre Julliard
Aug 27, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dwrite: Added IDWriteFontFamily stub.
parent
388f11ab
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
198 additions
and
4 deletions
+198
-4
font.c
dlls/dwrite/font.c
+142
-4
font.c
dlls/dwrite/tests/font.c
+56
-0
No files found.
dlls/dwrite/font.c
View file @
debc356a
...
@@ -27,10 +27,16 @@
...
@@ -27,10 +27,16 @@
WINE_DEFAULT_DEBUG_CHANNEL
(
dwrite
);
WINE_DEFAULT_DEBUG_CHANNEL
(
dwrite
);
struct
dwrite_fontfamily
{
IDWriteFontFamily
IDWriteFontFamily_iface
;
LONG
ref
;
};
struct
dwrite_font
{
struct
dwrite_font
{
IDWriteFont
IDWriteFont_iface
;
IDWriteFont
IDWriteFont_iface
;
LONG
ref
;
LONG
ref
;
IDWriteFontFamily
*
family
;
DWRITE_FONT_STYLE
style
;
DWRITE_FONT_STYLE
style
;
};
};
...
@@ -39,6 +45,11 @@ static inline struct dwrite_font *impl_from_IDWriteFont(IDWriteFont *iface)
...
@@ -39,6 +45,11 @@ static inline struct dwrite_font *impl_from_IDWriteFont(IDWriteFont *iface)
return
CONTAINING_RECORD
(
iface
,
struct
dwrite_font
,
IDWriteFont_iface
);
return
CONTAINING_RECORD
(
iface
,
struct
dwrite_font
,
IDWriteFont_iface
);
}
}
static
inline
struct
dwrite_fontfamily
*
impl_from_IDWriteFontFamily
(
IDWriteFontFamily
*
iface
)
{
return
CONTAINING_RECORD
(
iface
,
struct
dwrite_fontfamily
,
IDWriteFontFamily_iface
);
}
static
HRESULT
WINAPI
dwritefont_QueryInterface
(
IDWriteFont
*
iface
,
REFIID
riid
,
void
**
obj
)
static
HRESULT
WINAPI
dwritefont_QueryInterface
(
IDWriteFont
*
iface
,
REFIID
riid
,
void
**
obj
)
{
{
struct
dwrite_font
*
This
=
impl_from_IDWriteFont
(
iface
);
struct
dwrite_font
*
This
=
impl_from_IDWriteFont
(
iface
);
...
@@ -72,7 +83,10 @@ static ULONG WINAPI dwritefont_Release(IDWriteFont *iface)
...
@@ -72,7 +83,10 @@ static ULONG WINAPI dwritefont_Release(IDWriteFont *iface)
TRACE
(
"(%p)->(%d)
\n
"
,
This
,
ref
);
TRACE
(
"(%p)->(%d)
\n
"
,
This
,
ref
);
if
(
!
ref
)
if
(
!
ref
)
{
IDWriteFontFamily_Release
(
This
->
family
);
heap_free
(
This
);
heap_free
(
This
);
}
return
S_OK
;
return
S_OK
;
}
}
...
@@ -80,8 +94,11 @@ static ULONG WINAPI dwritefont_Release(IDWriteFont *iface)
...
@@ -80,8 +94,11 @@ static ULONG WINAPI dwritefont_Release(IDWriteFont *iface)
static
HRESULT
WINAPI
dwritefont_GetFontFamily
(
IDWriteFont
*
iface
,
IDWriteFontFamily
**
family
)
static
HRESULT
WINAPI
dwritefont_GetFontFamily
(
IDWriteFont
*
iface
,
IDWriteFontFamily
**
family
)
{
{
struct
dwrite_font
*
This
=
impl_from_IDWriteFont
(
iface
);
struct
dwrite_font
*
This
=
impl_from_IDWriteFont
(
iface
);
FIXME
(
"(%p)->(%p): stub
\n
"
,
This
,
family
);
TRACE
(
"(%p)->(%p)
\n
"
,
This
,
family
);
return
E_NOTIMPL
;
*
family
=
This
->
family
;
IDWriteFontFamily_AddRef
(
*
family
);
return
S_OK
;
}
}
static
DWRITE_FONT_WEIGHT
WINAPI
dwritefont_GetWeight
(
IDWriteFont
*
iface
)
static
DWRITE_FONT_WEIGHT
WINAPI
dwritefont_GetWeight
(
IDWriteFont
*
iface
)
...
@@ -171,18 +188,139 @@ static const IDWriteFontVtbl dwritefontvtbl = {
...
@@ -171,18 +188,139 @@ static const IDWriteFontVtbl dwritefontvtbl = {
dwritefont_CreateFontFace
dwritefont_CreateFontFace
};
};
static
HRESULT
WINAPI
dwritefontfamily_QueryInterface
(
IDWriteFontFamily
*
iface
,
REFIID
riid
,
void
**
obj
)
{
struct
dwrite_fontfamily
*
This
=
impl_from_IDWriteFontFamily
(
iface
);
TRACE
(
"(%p)->(%s %p)
\n
"
,
This
,
debugstr_guid
(
riid
),
obj
);
if
(
IsEqualIID
(
riid
,
&
IID_IUnknown
)
||
IsEqualIID
(
riid
,
&
IID_IDWriteFontList
)
||
IsEqualIID
(
riid
,
&
IID_IDWriteFontFamily
))
{
*
obj
=
iface
;
IDWriteFontFamily_AddRef
(
iface
);
return
S_OK
;
}
*
obj
=
NULL
;
return
E_NOINTERFACE
;
}
static
ULONG
WINAPI
dwritefontfamily_AddRef
(
IDWriteFontFamily
*
iface
)
{
struct
dwrite_fontfamily
*
This
=
impl_from_IDWriteFontFamily
(
iface
);
ULONG
ref
=
InterlockedIncrement
(
&
This
->
ref
);
TRACE
(
"(%p)->(%d)
\n
"
,
This
,
ref
);
return
ref
;
}
static
ULONG
WINAPI
dwritefontfamily_Release
(
IDWriteFontFamily
*
iface
)
{
struct
dwrite_fontfamily
*
This
=
impl_from_IDWriteFontFamily
(
iface
);
ULONG
ref
=
InterlockedDecrement
(
&
This
->
ref
);
TRACE
(
"(%p)->(%d)
\n
"
,
This
,
ref
);
if
(
!
ref
)
heap_free
(
This
);
return
S_OK
;
}
static
HRESULT
WINAPI
dwritefontfamily_GetFontCollection
(
IDWriteFontFamily
*
iface
,
IDWriteFontCollection
**
collection
)
{
struct
dwrite_fontfamily
*
This
=
impl_from_IDWriteFontFamily
(
iface
);
FIXME
(
"(%p)->(%p): stub
\n
"
,
This
,
collection
);
return
E_NOTIMPL
;
}
static
UINT32
WINAPI
dwritefontfamily_GetFontCount
(
IDWriteFontFamily
*
iface
)
{
struct
dwrite_fontfamily
*
This
=
impl_from_IDWriteFontFamily
(
iface
);
FIXME
(
"(%p): stub
\n
"
,
This
);
return
0
;
}
static
HRESULT
WINAPI
dwritefontfamily_GetFont
(
IDWriteFontFamily
*
iface
,
UINT32
index
,
IDWriteFont
**
font
)
{
struct
dwrite_fontfamily
*
This
=
impl_from_IDWriteFontFamily
(
iface
);
FIXME
(
"(%p)->(%u %p): stub
\n
"
,
This
,
index
,
font
);
return
E_NOTIMPL
;
}
static
HRESULT
WINAPI
dwritefontfamily_GetFamilyNames
(
IDWriteFontFamily
*
iface
,
IDWriteLocalizedStrings
**
names
)
{
struct
dwrite_fontfamily
*
This
=
impl_from_IDWriteFontFamily
(
iface
);
FIXME
(
"(%p)->(%p): stub
\n
"
,
This
,
names
);
return
E_NOTIMPL
;
}
static
HRESULT
WINAPI
dwritefontfamily_GetFirstMatchingFont
(
IDWriteFontFamily
*
iface
,
DWRITE_FONT_WEIGHT
weight
,
DWRITE_FONT_STRETCH
stretch
,
DWRITE_FONT_STYLE
style
,
IDWriteFont
**
font
)
{
struct
dwrite_fontfamily
*
This
=
impl_from_IDWriteFontFamily
(
iface
);
FIXME
(
"(%p)->(%d %d %d %p): stub
\n
"
,
This
,
weight
,
stretch
,
style
,
font
);
return
E_NOTIMPL
;
}
static
HRESULT
WINAPI
dwritefontfamily_GetMatchingFonts
(
IDWriteFontFamily
*
iface
,
DWRITE_FONT_WEIGHT
weight
,
DWRITE_FONT_STRETCH
stretch
,
DWRITE_FONT_STYLE
style
,
IDWriteFontList
**
fonts
)
{
struct
dwrite_fontfamily
*
This
=
impl_from_IDWriteFontFamily
(
iface
);
FIXME
(
"(%p)->(%d %d %d %p): stub
\n
"
,
This
,
weight
,
stretch
,
style
,
fonts
);
return
E_NOTIMPL
;
}
static
const
IDWriteFontFamilyVtbl
fontfamilyvtbl
=
{
dwritefontfamily_QueryInterface
,
dwritefontfamily_AddRef
,
dwritefontfamily_Release
,
dwritefontfamily_GetFontCollection
,
dwritefontfamily_GetFontCount
,
dwritefontfamily_GetFont
,
dwritefontfamily_GetFamilyNames
,
dwritefontfamily_GetFirstMatchingFont
,
dwritefontfamily_GetMatchingFonts
};
static
HRESULT
create_fontfamily
(
IDWriteFontFamily
**
family
)
{
struct
dwrite_fontfamily
*
This
;
*
family
=
NULL
;
This
=
heap_alloc
(
sizeof
(
struct
dwrite_fontfamily
));
if
(
!
This
)
return
E_OUTOFMEMORY
;
This
->
IDWriteFontFamily_iface
.
lpVtbl
=
&
fontfamilyvtbl
;
This
->
ref
=
1
;
*
family
=
&
This
->
IDWriteFontFamily_iface
;
return
S_OK
;
}
HRESULT
create_font_from_logfont
(
const
LOGFONTW
*
logfont
,
IDWriteFont
**
font
)
HRESULT
create_font_from_logfont
(
const
LOGFONTW
*
logfont
,
IDWriteFont
**
font
)
{
{
struct
dwrite_font
*
This
;
struct
dwrite_font
*
This
;
IDWriteFontFamily
*
family
;
HRESULT
hr
;
*
font
=
NULL
;
*
font
=
NULL
;
hr
=
create_fontfamily
(
&
family
);
if
(
hr
!=
S_OK
)
return
hr
;
This
=
heap_alloc
(
sizeof
(
struct
dwrite_font
));
This
=
heap_alloc
(
sizeof
(
struct
dwrite_font
));
if
(
!
This
)
return
E_OUTOFMEMORY
;
if
(
!
This
)
{
IDWriteFontFamily_Release
(
family
);
return
E_OUTOFMEMORY
;
}
This
->
IDWriteFont_iface
.
lpVtbl
=
&
dwritefontvtbl
;
This
->
IDWriteFont_iface
.
lpVtbl
=
&
dwritefontvtbl
;
This
->
ref
=
1
;
This
->
ref
=
1
;
This
->
family
=
family
;
This
->
style
=
logfont
->
lfItalic
?
DWRITE_FONT_STYLE_ITALIC
:
DWRITE_FONT_STYLE_NORMAL
;
This
->
style
=
logfont
->
lfItalic
?
DWRITE_FONT_STYLE_ITALIC
:
DWRITE_FONT_STYLE_NORMAL
;
*
font
=
&
This
->
IDWriteFont_iface
;
*
font
=
&
This
->
IDWriteFont_iface
;
...
...
dlls/dwrite/tests/font.c
View file @
debc356a
...
@@ -30,6 +30,14 @@
...
@@ -30,6 +30,14 @@
#define EXPECT_HR(hr,hr_exp) \
#define EXPECT_HR(hr,hr_exp) \
ok(hr == hr_exp, "got 0x%08x, expected 0x%08x\n", hr, hr_exp)
ok(hr == hr_exp, "got 0x%08x, expected 0x%08x\n", hr, hr_exp)
#define EXPECT_REF(obj,ref) _expect_ref((IUnknown*)obj, ref, __LINE__)
static
void
_expect_ref
(
IUnknown
*
obj
,
ULONG
ref
,
int
line
)
{
ULONG
rc
=
IUnknown_AddRef
(
obj
);
IUnknown_Release
(
obj
);
ok_
(
__FILE__
,
line
)(
rc
-
1
==
ref
,
"expected refcount %d, got %d
\n
"
,
ref
,
rc
-
1
);
}
static
IDWriteFactory
*
factory
;
static
IDWriteFactory
*
factory
;
static
void
test_CreateFontFromLOGFONT
(
void
)
static
void
test_CreateFontFromLOGFONT
(
void
)
...
@@ -234,6 +242,53 @@ if (0) /* crashes on native */
...
@@ -234,6 +242,53 @@ if (0) /* crashes on native */
IDWriteGdiInterop_Release
(
interop
);
IDWriteGdiInterop_Release
(
interop
);
}
}
static
void
test_GetFontFamily
(
void
)
{
static
const
WCHAR
arialW
[]
=
{
'A'
,
'r'
,
'i'
,
'a'
,
'l'
,
0
};
IDWriteFontFamily
*
family
,
*
family2
;
IDWriteGdiInterop
*
interop
;
IDWriteFont
*
font
;
LOGFONTW
logfont
;
HRESULT
hr
;
hr
=
IDWriteFactory_GetGdiInterop
(
factory
,
&
interop
);
EXPECT_HR
(
hr
,
S_OK
);
memset
(
&
logfont
,
0
,
sizeof
(
logfont
));
logfont
.
lfHeight
=
12
;
logfont
.
lfWidth
=
12
;
logfont
.
lfWeight
=
FW_NORMAL
;
logfont
.
lfItalic
=
1
;
lstrcpyW
(
logfont
.
lfFaceName
,
arialW
);
hr
=
IDWriteGdiInterop_CreateFontFromLOGFONT
(
interop
,
&
logfont
,
&
font
);
EXPECT_HR
(
hr
,
S_OK
);
if
(
0
)
/* crashes on native */
hr
=
IDWriteFont_GetFontFamily
(
font
,
NULL
);
EXPECT_REF
(
font
,
1
);
hr
=
IDWriteFont_GetFontFamily
(
font
,
&
family
);
EXPECT_HR
(
hr
,
S_OK
);
EXPECT_REF
(
font
,
1
);
EXPECT_REF
(
family
,
2
);
hr
=
IDWriteFont_GetFontFamily
(
font
,
&
family2
);
EXPECT_HR
(
hr
,
S_OK
);
ok
(
family2
==
family
,
"got %p, previous %p
\n
"
,
family2
,
family
);
EXPECT_REF
(
font
,
1
);
EXPECT_REF
(
family
,
3
);
IDWriteFontFamily_Release
(
family2
);
hr
=
IDWriteFont_QueryInterface
(
font
,
&
IID_IDWriteFontFamily
,
(
void
**
)
&
family2
);
EXPECT_HR
(
hr
,
E_NOINTERFACE
);
ok
(
family2
==
NULL
,
"got %p
\n
"
,
family2
);
IDWriteFontFamily_Release
(
family
);
IDWriteFont_Release
(
font
);
IDWriteGdiInterop_Release
(
interop
);
}
START_TEST
(
font
)
START_TEST
(
font
)
{
{
HRESULT
hr
;
HRESULT
hr
;
...
@@ -248,6 +303,7 @@ START_TEST(font)
...
@@ -248,6 +303,7 @@ START_TEST(font)
test_CreateFontFromLOGFONT
();
test_CreateFontFromLOGFONT
();
test_CreateBitmapRenderTarget
();
test_CreateBitmapRenderTarget
();
test_GetFontFamily
();
IDWriteFactory_Release
(
factory
);
IDWriteFactory_Release
(
factory
);
}
}
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