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
0358413e
Commit
0358413e
authored
Oct 12, 2012
by
Nikolay Sivov
Committed by
Alexandre Julliard
Oct 12, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dwrite: Implement GetWeight() for IDWriteFont.
parent
ab91abd7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
28 deletions
+30
-28
font.c
dlls/dwrite/font.c
+30
-25
font.c
dlls/dwrite/tests/font.c
+0
-3
No files found.
dlls/dwrite/font.c
View file @
0358413e
...
...
@@ -105,6 +105,7 @@ struct dwrite_font {
IDWriteFontFace
*
face
;
DWRITE_FONT_STYLE
style
;
DWRITE_FONT_STRETCH
stretch
;
DWRITE_FONT_WEIGHT
weight
;
};
struct
dwrite_fontface
{
...
...
@@ -371,8 +372,8 @@ static HRESULT WINAPI dwritefont_GetFontFamily(IDWriteFont *iface, IDWriteFontFa
static
DWRITE_FONT_WEIGHT
WINAPI
dwritefont_GetWeight
(
IDWriteFont
*
iface
)
{
struct
dwrite_font
*
This
=
impl_from_IDWriteFont
(
iface
);
FIXME
(
"(%p): stub
\n
"
,
This
);
return
0
;
TRACE
(
"(%p)
\n
"
,
This
);
return
This
->
weight
;
}
static
DWRITE_FONT_STRETCH
WINAPI
dwritefont_GetStretch
(
IDWriteFont
*
iface
)
...
...
@@ -592,28 +593,30 @@ static HRESULT create_fontfamily(const WCHAR *familyname, IDWriteFontFamily **fa
return
S_OK
;
}
static
DWRITE_FONT_STRETCH
get_font_stretch
(
HDC
hdc
)
static
void
get_font_properties
(
struct
dwrite_font
*
font
,
HDC
hdc
)
{
DWRITE_FONT_STRETCH
stretch
;
TT_OS2_V2
tt_os2
;
LONG
size
;
/* default stretch to normal */
stretch
=
DWRITE_FONT_STRETCH_NORMAL
;
/* default stretch and weight to normal */
font
->
stretch
=
DWRITE_FONT_STRETCH_NORMAL
;
font
->
weight
=
DWRITE_FONT_WEIGHT_NORMAL
;
size
=
GetFontData
(
hdc
,
MS_OS2_TAG
,
0
,
NULL
,
0
);
if
(
size
==
GDI_ERROR
)
return
stretch
;
if
(
size
>
sizeof
(
tt_os2
))
size
=
sizeof
(
tt_os2
);
if
(
size
!=
GDI_ERROR
)
{
if
(
size
>
sizeof
(
tt_os2
))
size
=
sizeof
(
tt_os2
);
memset
(
&
tt_os2
,
0
,
sizeof
(
tt_os2
));
if
(
GetFontData
(
hdc
,
MS_OS2_TAG
,
0
,
&
tt_os2
,
size
)
!=
size
)
return
stretch
;
memset
(
&
tt_os2
,
0
,
sizeof
(
tt_os2
));
if
(
GetFontData
(
hdc
,
MS_OS2_TAG
,
0
,
&
tt_os2
,
size
)
!=
size
)
return
;
/* DWRITE_FONT_STRETCH enumeration values directly match font data values */
if
(
GET_BE_WORD
(
tt_os2
.
usWidthClass
)
<=
DWRITE_FONT_STRETCH_ULTRA_EXPANDED
)
stretch
=
GET_BE_WORD
(
tt_os2
.
usWidthClass
);
/* DWRITE_FONT_STRETCH enumeration values directly match font data values */
if
(
GET_BE_WORD
(
tt_os2
.
usWidthClass
)
<=
DWRITE_FONT_STRETCH_ULTRA_EXPANDED
)
font
->
stretch
=
GET_BE_WORD
(
tt_os2
.
usWidthClass
);
return
stretch
;
font
->
weight
=
GET_BE_WORD
(
tt_os2
.
usWeightClass
);
TRACE
(
"stretch=%d, weight=%d
\n
"
,
font
->
stretch
,
font
->
weight
);
}
}
HRESULT
create_font_from_logfont
(
const
LOGFONTW
*
logfont
,
IDWriteFont
**
font
)
...
...
@@ -622,7 +625,6 @@ HRESULT create_font_from_logfont(const LOGFONTW *logfont, IDWriteFont **font)
struct
dwrite_font
*
This
;
IDWriteFontFamily
*
family
;
OUTLINETEXTMETRICW
*
otm
;
DWRITE_FONT_STRETCH
stretch
;
HRESULT
hr
;
HFONT
hfont
;
HDC
hdc
;
...
...
@@ -630,8 +632,15 @@ HRESULT create_font_from_logfont(const LOGFONTW *logfont, IDWriteFont **font)
*
font
=
NULL
;
This
=
heap_alloc
(
sizeof
(
struct
dwrite_font
));
if
(
!
This
)
return
E_OUTOFMEMORY
;
hfont
=
CreateFontIndirectW
(
logfont
);
if
(
!
hfont
)
return
DWRITE_E_NOFONT
;
if
(
!
hfont
)
{
heap_free
(
This
);
return
DWRITE_E_NOFONT
;
}
hdc
=
CreateCompatibleDC
(
0
);
SelectObject
(
hdc
,
hfont
);
...
...
@@ -641,7 +650,7 @@ HRESULT create_font_from_logfont(const LOGFONTW *logfont, IDWriteFont **font)
otm
->
otmSize
=
ret
;
ret
=
GetOutlineTextMetricsW
(
hdc
,
otm
->
otmSize
,
otm
);
stretch
=
get_font_stretch
(
hdc
);
get_font_properties
(
This
,
hdc
);
DeleteDC
(
hdc
);
DeleteObject
(
hfont
);
...
...
@@ -652,13 +661,10 @@ HRESULT create_font_from_logfont(const LOGFONTW *logfont, IDWriteFont **font)
hr
=
create_fontfamily
(
familyname
,
&
family
);
heap_free
(
otm
);
if
(
hr
!=
S_OK
)
return
hr
;
This
=
heap_alloc
(
sizeof
(
struct
dwrite_font
));
if
(
!
This
)
if
(
hr
!=
S_OK
)
{
IDWriteFontFamily_Release
(
family
);
return
E_OUTOFMEMORY
;
heap_free
(
This
);
return
hr
;
}
This
->
IDWriteFont_iface
.
lpVtbl
=
&
dwritefontvtbl
;
...
...
@@ -666,7 +672,6 @@ HRESULT create_font_from_logfont(const LOGFONTW *logfont, IDWriteFont **font)
This
->
face
=
NULL
;
This
->
family
=
family
;
This
->
style
=
logfont
->
lfItalic
?
DWRITE_FONT_STYLE_ITALIC
:
DWRITE_FONT_STYLE_NORMAL
;
This
->
stretch
=
stretch
;
*
font
=
&
This
->
IDWriteFont_iface
;
...
...
dlls/dwrite/tests/font.c
View file @
0358413e
...
...
@@ -91,7 +91,6 @@ if (0)
/* now check properties */
weight
=
IDWriteFont_GetWeight
(
font
);
todo_wine
ok
(
weight
==
DWRITE_FONT_WEIGHT_NORMAL
,
"got %d
\n
"
,
weight
);
style
=
IDWriteFont_GetStyle
(
font
);
...
...
@@ -115,7 +114,6 @@ todo_wine
EXPECT_HR
(
hr
,
S_OK
);
weight
=
IDWriteFont_GetWeight
(
font
);
todo_wine
ok
(
weight
==
weights
[
i
][
1
],
"%d: got %d, expected %d
\n
"
,
i
,
weight
,
weights
[
i
][
1
]);
IDWriteFont_Release
(
font
);
...
...
@@ -132,7 +130,6 @@ todo_wine
EXPECT_HR
(
hr
,
S_OK
);
weight
=
IDWriteFont_GetWeight
(
font
);
todo_wine
ok
(
weight
==
DWRITE_FONT_WEIGHT_NORMAL
||
broken
(
weight
==
DWRITE_FONT_WEIGHT_BOLD
)
/* win7 w/o SP */
,
"got %d
\n
"
,
weight
);
IDWriteFont_Release
(
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