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
689683df
Commit
689683df
authored
Nov 05, 2018
by
Nikolay Sivov
Committed by
Alexandre Julliard
Nov 05, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dwrite/layout: Set default tab stop width.
Signed-off-by:
Nikolay Sivov
<
nsivov@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
70654e5c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
106 additions
and
7 deletions
+106
-7
layout.c
dlls/dwrite/layout.c
+21
-6
layout.c
dlls/dwrite/tests/layout.c
+85
-1
No files found.
dlls/dwrite/layout.c
View file @
689683df
...
...
@@ -53,6 +53,7 @@ struct dwrite_textformat_data {
DWRITE_LINE_SPACING
spacing
;
FLOAT
fontsize
;
FLOAT
tabstop
;
DWRITE_TRIMMING
trimming
;
IDWriteInlineObject
*
trimmingsign
;
...
...
@@ -4272,7 +4273,13 @@ static HRESULT WINAPI dwritetextformat_layout_SetFlowDirection(IDWriteTextFormat
static
HRESULT
WINAPI
dwritetextformat_layout_SetIncrementalTabStop
(
IDWriteTextFormat2
*
iface
,
FLOAT
tabstop
)
{
struct
dwrite_textlayout
*
This
=
impl_layout_from_IDWriteTextFormat2
(
iface
);
FIXME
(
"(%p)->(%f): stub
\n
"
,
This
,
tabstop
);
TRACE
(
"(%p)->(%f)
\n
"
,
This
,
tabstop
);
if
(
tabstop
<=
0
.
0
f
)
return
E_INVALIDARG
;
This
->
format
.
tabstop
=
tabstop
;
return
S_OK
;
}
...
...
@@ -4346,8 +4353,8 @@ static DWRITE_FLOW_DIRECTION WINAPI dwritetextformat_layout_GetFlowDirection(IDW
static
FLOAT
WINAPI
dwritetextformat_layout_GetIncrementalTabStop
(
IDWriteTextFormat2
*
iface
)
{
struct
dwrite_textlayout
*
This
=
impl_layout_from_IDWriteTextFormat2
(
iface
);
FIXME
(
"(%p): stub
\n
"
,
This
);
return
0
.
0
f
;
TRACE
(
"(%p)
\n
"
,
This
);
return
This
->
format
.
tabstop
;
}
static
HRESULT
WINAPI
dwritetextformat_layout_GetTrimming
(
IDWriteTextFormat2
*
iface
,
DWRITE_TRIMMING
*
options
,
...
...
@@ -4875,6 +4882,7 @@ static HRESULT layout_format_from_textformat(struct dwrite_textlayout *layout, I
layout
->
format
.
style
=
IDWriteTextFormat_GetFontStyle
(
format
);
layout
->
format
.
stretch
=
IDWriteTextFormat_GetFontStretch
(
format
);
layout
->
format
.
fontsize
=
IDWriteTextFormat_GetFontSize
(
format
);
layout
->
format
.
tabstop
=
IDWriteTextFormat_GetIncrementalTabStop
(
format
);
layout
->
format
.
textalignment
=
IDWriteTextFormat_GetTextAlignment
(
format
);
layout
->
format
.
paralign
=
IDWriteTextFormat_GetParagraphAlignment
(
format
);
layout
->
format
.
wrapping
=
IDWriteTextFormat_GetWordWrapping
(
format
);
...
...
@@ -5302,7 +5310,13 @@ static HRESULT WINAPI dwritetextformat_SetFlowDirection(IDWriteTextFormat2 *ifac
static
HRESULT
WINAPI
dwritetextformat_SetIncrementalTabStop
(
IDWriteTextFormat2
*
iface
,
FLOAT
tabstop
)
{
struct
dwrite_textformat
*
This
=
impl_from_IDWriteTextFormat2
(
iface
);
FIXME
(
"(%p)->(%f): stub
\n
"
,
This
,
tabstop
);
TRACE
(
"(%p)->(%f)
\n
"
,
This
,
tabstop
);
if
(
tabstop
<=
0
.
0
f
)
return
E_INVALIDARG
;
This
->
format
.
tabstop
=
tabstop
;
return
S_OK
;
}
...
...
@@ -5368,8 +5382,8 @@ static DWRITE_FLOW_DIRECTION WINAPI dwritetextformat_GetFlowDirection(IDWriteTex
static
FLOAT
WINAPI
dwritetextformat_GetIncrementalTabStop
(
IDWriteTextFormat2
*
iface
)
{
struct
dwrite_textformat
*
This
=
impl_from_IDWriteTextFormat2
(
iface
);
FIXME
(
"(%p): stub
\n
"
,
This
);
return
0
.
0
f
;
TRACE
(
"(%p)
\n
"
,
This
);
return
This
->
format
.
tabstop
;
}
static
HRESULT
WINAPI
dwritetextformat_GetTrimming
(
IDWriteTextFormat2
*
iface
,
DWRITE_TRIMMING
*
options
,
...
...
@@ -5631,6 +5645,7 @@ HRESULT create_textformat(const WCHAR *family_name, IDWriteFontCollection *colle
This
->
format
.
weight
=
weight
;
This
->
format
.
style
=
style
;
This
->
format
.
fontsize
=
size
;
This
->
format
.
tabstop
=
4
.
0
f
*
size
;
This
->
format
.
stretch
=
stretch
;
This
->
format
.
textalignment
=
DWRITE_TEXT_ALIGNMENT_LEADING
;
This
->
format
.
optical_alignment
=
DWRITE_OPTICAL_ALIGNMENT_NONE
;
...
...
dlls/dwrite/tests/layout.c
View file @
689683df
...
...
@@ -4972,7 +4972,6 @@ todo_wine {
IDWriteFactory_Release
(
factory
);
}
static
void
test_SetTypography
(
void
)
{
static
const
WCHAR
strW
[]
=
{
'a'
,
'f'
,
'i'
,
'b'
,
0
};
...
...
@@ -5599,6 +5598,90 @@ static void test_GetOverhangMetrics(void)
IDWriteFactory_Release
(
factory
);
}
static
void
test_tab_stops
(
void
)
{
static
const
WCHAR
strW
[]
=
{
'\t'
,
'a'
,
'\t'
,
'b'
};
DWRITE_CLUSTER_METRICS
clusters
[
4
];
IDWriteTextLayout
*
layout
;
IDWriteTextFormat
*
format
;
IDWriteFactory
*
factory
;
DWRITE_TEXT_RANGE
range
;
FLOAT
tabstop
,
size
;
ULONG
count
;
HRESULT
hr
;
factory
=
create_factory
();
/* Default tab stop value. */
for
(
size
=
1
.
0
f
;
size
<
25
.
0
f
;
size
+=
5
.
0
f
)
{
hr
=
IDWriteFactory_CreateTextFormat
(
factory
,
tahomaW
,
NULL
,
DWRITE_FONT_WEIGHT_NORMAL
,
DWRITE_FONT_STYLE_NORMAL
,
DWRITE_FONT_STRETCH_NORMAL
,
size
,
enusW
,
&
format
);
ok
(
hr
==
S_OK
,
"Failed to create text format, hr %#x.
\n
"
,
hr
);
tabstop
=
IDWriteTextFormat_GetIncrementalTabStop
(
format
);
ok
(
tabstop
==
4
.
0
f
*
size
,
"Unexpected tab stop %f.
\n
"
,
tabstop
);
IDWriteTextFormat_Release
(
format
);
}
hr
=
IDWriteFactory_CreateTextFormat
(
factory
,
tahomaW
,
NULL
,
DWRITE_FONT_WEIGHT_NORMAL
,
DWRITE_FONT_STYLE_NORMAL
,
DWRITE_FONT_STRETCH_NORMAL
,
10
.
0
f
,
enusW
,
&
format
);
ok
(
hr
==
S_OK
,
"Failed to create text format, hr %#x.
\n
"
,
hr
);
hr
=
IDWriteTextFormat_SetIncrementalTabStop
(
format
,
0
.
0
f
);
ok
(
hr
==
E_INVALIDARG
,
"Unexpected hr %#x.
\n
"
,
hr
);
hr
=
IDWriteTextFormat_SetIncrementalTabStop
(
format
,
-
10
.
0
f
);
ok
(
hr
==
E_INVALIDARG
,
"Unexpected hr %#x.
\n
"
,
hr
);
tabstop
=
IDWriteTextFormat_GetIncrementalTabStop
(
format
);
ok
(
tabstop
==
40
.
0
f
,
"Unexpected tab stop %f.
\n
"
,
tabstop
);
hr
=
IDWriteTextFormat_SetIncrementalTabStop
(
format
,
100
.
0
f
);
ok
(
hr
==
S_OK
,
"Failed to set tab stop value, hr %#x.
\n
"
,
hr
);
tabstop
=
IDWriteTextFormat_GetIncrementalTabStop
(
format
);
ok
(
tabstop
==
100
.
0
f
,
"Unexpected tab stop %f.
\n
"
,
tabstop
);
hr
=
IDWriteFactory_CreateTextLayout
(
factory
,
strW
,
4
,
format
,
1000
.
0
f
,
1000
.
0
f
,
&
layout
);
ok
(
hr
==
S_OK
,
"Failed to create text layout, hr %x.
\n
"
,
hr
);
hr
=
IDWriteTextLayout_GetClusterMetrics
(
layout
,
clusters
,
4
,
&
count
);
ok
(
hr
==
S_OK
,
"Failed to get cluster metrics, hr %#x.
\n
"
,
hr
);
ok
(
clusters
[
0
].
isWhitespace
,
"Unexpected isWhitespace.
\n
"
);
ok
(
!
clusters
[
1
].
isWhitespace
,
"Unexpected isWhitespace.
\n
"
);
ok
(
clusters
[
2
].
isWhitespace
,
"Unexpected isWhitespace.
\n
"
);
ok
(
!
clusters
[
3
].
isWhitespace
,
"Unexpected isWhitespace.
\n
"
);
todo_wine
{
ok
(
clusters
[
0
].
width
==
tabstop
,
"Unexpected tab width.
\n
"
);
ok
(
clusters
[
1
].
width
+
clusters
[
2
].
width
==
tabstop
,
"Unexpected tab width.
\n
"
);
}
range
.
startPosition
=
0
;
range
.
length
=
~
0u
;
hr
=
IDWriteTextLayout_SetFontSize
(
layout
,
20
.
0
f
,
range
);
ok
(
hr
==
S_OK
,
"Failed to set font size, hr %#x.
\n
"
,
hr
);
tabstop
=
IDWriteTextLayout_GetIncrementalTabStop
(
layout
);
ok
(
tabstop
==
100
.
0
f
,
"Unexpected tab stop %f.
\n
"
,
tabstop
);
hr
=
IDWriteTextLayout_GetClusterMetrics
(
layout
,
clusters
,
4
,
&
count
);
ok
(
hr
==
S_OK
,
"Failed to get cluster metrics, hr %#x.
\n
"
,
hr
);
ok
(
clusters
[
0
].
isWhitespace
,
"Unexpected isWhitespace.
\n
"
);
ok
(
!
clusters
[
1
].
isWhitespace
,
"Unexpected isWhitespace.
\n
"
);
ok
(
clusters
[
2
].
isWhitespace
,
"Unexpected isWhitespace.
\n
"
);
ok
(
!
clusters
[
3
].
isWhitespace
,
"Unexpected isWhitespace.
\n
"
);
todo_wine
{
ok
(
clusters
[
0
].
width
==
tabstop
,
"Unexpected tab width.
\n
"
);
ok
(
clusters
[
1
].
width
+
clusters
[
2
].
width
==
tabstop
,
"Unexpected tab width.
\n
"
);
}
IDWriteTextLayout_Release
(
layout
);
IDWriteTextFormat_Release
(
format
);
IDWriteFactory_Release
(
factory
);
}
START_TEST
(
layout
)
{
IDWriteFactory
*
factory
;
...
...
@@ -5649,6 +5732,7 @@ START_TEST(layout)
test_InvalidateLayout
();
test_line_spacing
();
test_GetOverhangMetrics
();
test_tab_stops
();
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