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
6d52bc59
Commit
6d52bc59
authored
Jul 09, 2015
by
Nikolay Sivov
Committed by
Alexandre Julliard
Jul 09, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dwrite: Implement SetReadingDirection() for layout.
parent
577332f6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
119 additions
and
10 deletions
+119
-10
layout.c
dlls/dwrite/layout.c
+24
-10
layout.c
dlls/dwrite/tests/layout.c
+95
-0
No files found.
dlls/dwrite/layout.c
View file @
6d52bc59
...
...
@@ -352,6 +352,16 @@ static inline HRESULT format_set_paralignment(struct dwrite_textformat_data *for
return
S_OK
;
}
static
inline
HRESULT
format_set_readingdirection
(
struct
dwrite_textformat_data
*
format
,
DWRITE_READING_DIRECTION
direction
,
BOOL
*
changed
)
{
if
((
UINT32
)
direction
>
DWRITE_READING_DIRECTION_BOTTOM_TO_TOP
)
return
E_INVALIDARG
;
if
(
changed
)
*
changed
=
format
->
readingdir
!=
direction
;
format
->
readingdir
=
direction
;
return
S_OK
;
}
static
HRESULT
get_fontfallback_from_format
(
const
struct
dwrite_textformat_data
*
format
,
IDWriteFontFallback
**
fallback
)
{
*
fallback
=
format
->
fallback
;
...
...
@@ -2168,7 +2178,6 @@ static HRESULT WINAPI dwritetextlayout_SetWordWrapping(IDWriteTextLayout2 *iface
static
HRESULT
WINAPI
dwritetextlayout_SetReadingDirection
(
IDWriteTextLayout2
*
iface
,
DWRITE_READING_DIRECTION
direction
)
{
struct
dwrite_textlayout
*
This
=
impl_from_IDWriteTextLayout2
(
iface
);
TRACE
(
"(%p)->(%d)
\n
"
,
This
,
direction
);
return
IDWriteTextFormat1_SetReadingDirection
(
&
This
->
IDWriteTextFormat1_iface
,
direction
);
}
...
...
@@ -3208,8 +3217,19 @@ static HRESULT WINAPI dwritetextformat1_layout_SetWordWrapping(IDWriteTextFormat
static
HRESULT
WINAPI
dwritetextformat1_layout_SetReadingDirection
(
IDWriteTextFormat1
*
iface
,
DWRITE_READING_DIRECTION
direction
)
{
struct
dwrite_textlayout
*
This
=
impl_layout_form_IDWriteTextFormat1
(
iface
);
FIXME
(
"(%p)->(%d): stub
\n
"
,
This
,
direction
);
return
E_NOTIMPL
;
BOOL
changed
;
HRESULT
hr
;
TRACE
(
"(%p)->(%d)
\n
"
,
This
,
direction
);
hr
=
format_set_readingdirection
(
&
This
->
format
,
direction
,
&
changed
);
if
(
FAILED
(
hr
))
return
hr
;
if
(
changed
)
This
->
recompute
=
RECOMPUTE_EVERYTHING
;
return
S_OK
;
}
static
HRESULT
WINAPI
dwritetextformat1_layout_SetFlowDirection
(
IDWriteTextFormat1
*
iface
,
DWRITE_FLOW_DIRECTION
direction
)
...
...
@@ -4088,14 +4108,8 @@ static HRESULT WINAPI dwritetextformat_SetWordWrapping(IDWriteTextFormat1 *iface
static
HRESULT
WINAPI
dwritetextformat_SetReadingDirection
(
IDWriteTextFormat1
*
iface
,
DWRITE_READING_DIRECTION
direction
)
{
struct
dwrite_textformat
*
This
=
impl_from_IDWriteTextFormat1
(
iface
);
TRACE
(
"(%p)->(%d)
\n
"
,
This
,
direction
);
if
((
UINT32
)
direction
>
DWRITE_READING_DIRECTION_BOTTOM_TO_TOP
)
return
E_INVALIDARG
;
This
->
format
.
readingdir
=
direction
;
return
S_OK
;
return
format_set_readingdirection
(
&
This
->
format
,
direction
,
NULL
);
}
static
HRESULT
WINAPI
dwritetextformat_SetFlowDirection
(
IDWriteTextFormat1
*
iface
,
DWRITE_FLOW_DIRECTION
direction
)
...
...
dlls/dwrite/tests/layout.c
View file @
6d52bc59
...
...
@@ -3120,6 +3120,100 @@ static void test_SetParagraphAlignment(void)
IDWriteFactory_Release
(
factory
);
}
static
void
test_SetReadingDirection
(
void
)
{
static
const
WCHAR
strW
[]
=
{
'a'
,
0
};
DWRITE_CLUSTER_METRICS
clusters
[
1
];
DWRITE_TEXT_METRICS
metrics
;
IDWriteTextFormat
*
format
;
IDWriteTextLayout
*
layout
;
IDWriteFactory
*
factory
;
DWRITE_READING_DIRECTION
v
;
DWRITE_LINE_METRICS
lines
[
1
];
UINT32
count
;
HRESULT
hr
;
factory
=
create_factory
();
hr
=
IDWriteFactory_CreateTextFormat
(
factory
,
tahomaW
,
NULL
,
DWRITE_FONT_WEIGHT_NORMAL
,
DWRITE_FONT_STYLE_NORMAL
,
DWRITE_FONT_STRETCH_NORMAL
,
12
.
0
,
enusW
,
&
format
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
v
=
IDWriteTextFormat_GetReadingDirection
(
format
);
ok
(
v
==
DWRITE_READING_DIRECTION_LEFT_TO_RIGHT
,
"got %d
\n
"
,
v
);
hr
=
IDWriteFactory_CreateTextLayout
(
factory
,
strW
,
1
,
format
,
500
.
0
,
100
.
0
,
&
layout
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
v
=
IDWriteTextLayout_GetReadingDirection
(
layout
);
ok
(
v
==
DWRITE_READING_DIRECTION_LEFT_TO_RIGHT
,
"got %d
\n
"
,
v
);
v
=
IDWriteTextFormat_GetReadingDirection
(
format
);
ok
(
v
==
DWRITE_READING_DIRECTION_LEFT_TO_RIGHT
,
"got %d
\n
"
,
v
);
hr
=
IDWriteTextLayout_SetReadingDirection
(
layout
,
DWRITE_READING_DIRECTION_RIGHT_TO_LEFT
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
count
=
0
;
hr
=
IDWriteTextLayout_GetLineMetrics
(
layout
,
lines
,
1
,
&
count
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
ok
(
count
==
1
,
"got %u
\n
"
,
count
);
count
=
0
;
hr
=
IDWriteTextLayout_GetClusterMetrics
(
layout
,
clusters
,
1
,
&
count
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
ok
(
count
==
1
,
"got %u
\n
"
,
count
);
/* leading alignment, RTL */
hr
=
IDWriteTextLayout_GetMetrics
(
layout
,
&
metrics
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
todo_wine
ok
(
metrics
.
left
==
metrics
.
layoutWidth
-
clusters
[
0
].
width
,
"got %.2f
\n
"
,
metrics
.
left
);
ok
(
metrics
.
top
==
0
.
0
,
"got %.2f
\n
"
,
metrics
.
top
);
ok
(
metrics
.
width
==
clusters
[
0
].
width
,
"got %.2f
\n
"
,
metrics
.
width
);
ok
(
metrics
.
height
==
lines
[
0
].
height
,
"got %.2f
\n
"
,
metrics
.
height
);
ok
(
metrics
.
layoutWidth
==
500
.
0
,
"got %.2f
\n
"
,
metrics
.
layoutWidth
);
ok
(
metrics
.
layoutHeight
==
100
.
0
,
"got %.2f
\n
"
,
metrics
.
layoutHeight
);
ok
(
metrics
.
lineCount
==
1
,
"got %d
\n
"
,
metrics
.
lineCount
);
/* trailing alignment, RTL */
hr
=
IDWriteTextLayout_SetTextAlignment
(
layout
,
DWRITE_TEXT_ALIGNMENT_TRAILING
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IDWriteTextLayout_GetMetrics
(
layout
,
&
metrics
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
todo_wine
ok
(
metrics
.
left
==
0
.
0
,
"got %.2f
\n
"
,
metrics
.
left
);
ok
(
metrics
.
top
==
0
.
0
,
"got %.2f
\n
"
,
metrics
.
top
);
ok
(
metrics
.
width
==
clusters
[
0
].
width
,
"got %.2f
\n
"
,
metrics
.
width
);
ok
(
metrics
.
height
==
lines
[
0
].
height
,
"got %.2f
\n
"
,
metrics
.
height
);
ok
(
metrics
.
layoutWidth
==
500
.
0
,
"got %.2f
\n
"
,
metrics
.
layoutWidth
);
ok
(
metrics
.
layoutHeight
==
100
.
0
,
"got %.2f
\n
"
,
metrics
.
layoutHeight
);
ok
(
metrics
.
lineCount
==
1
,
"got %d
\n
"
,
metrics
.
lineCount
);
/* centered alignment, RTL */
hr
=
IDWriteTextLayout_SetTextAlignment
(
layout
,
DWRITE_TEXT_ALIGNMENT_CENTER
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IDWriteTextLayout_GetMetrics
(
layout
,
&
metrics
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
ok
(
metrics
.
left
==
(
metrics
.
layoutWidth
-
clusters
[
0
].
width
)
/
2
.
0
,
"got %.2f
\n
"
,
metrics
.
left
);
ok
(
metrics
.
top
==
0
.
0
,
"got %.2f
\n
"
,
metrics
.
top
);
ok
(
metrics
.
width
==
clusters
[
0
].
width
,
"got %.2f
\n
"
,
metrics
.
width
);
ok
(
metrics
.
height
==
lines
[
0
].
height
,
"got %.2f
\n
"
,
metrics
.
height
);
ok
(
metrics
.
layoutWidth
==
500
.
0
,
"got %.2f
\n
"
,
metrics
.
layoutWidth
);
ok
(
metrics
.
layoutHeight
==
100
.
0
,
"got %.2f
\n
"
,
metrics
.
layoutHeight
);
ok
(
metrics
.
lineCount
==
1
,
"got %d
\n
"
,
metrics
.
lineCount
);
IDWriteTextLayout_Release
(
layout
);
IDWriteTextFormat_Release
(
format
);
IDWriteFactory_Release
(
factory
);
}
START_TEST
(
layout
)
{
static
const
WCHAR
ctrlstrW
[]
=
{
0x202a
,
0
};
...
...
@@ -3162,6 +3256,7 @@ START_TEST(layout)
test_GetLineMetrics
();
test_SetTextAlignment
();
test_SetParagraphAlignment
();
test_SetReadingDirection
();
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