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
9ec714db
Commit
9ec714db
authored
Jul 25, 2016
by
Nikolay Sivov
Committed by
Alexandre Julliard
Jul 25, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dwrite: Implement newer SetLineSpacing/GetLineSpacing.
Signed-off-by:
Nikolay Sivov
<
nsivov@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
0d57ff3d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
165 additions
and
55 deletions
+165
-55
layout.c
dlls/dwrite/layout.c
+74
-44
layout.c
dlls/dwrite/tests/layout.c
+91
-11
No files found.
dlls/dwrite/layout.c
View file @
9ec714db
...
...
@@ -47,12 +47,10 @@ struct dwrite_textformat_data {
BOOL
last_line_wrapping
;
DWRITE_TEXT_ALIGNMENT
textalignment
;
DWRITE_FLOW_DIRECTION
flow
;
DWRITE_LINE_SPACING_METHOD
spacingmethod
;
DWRITE_VERTICAL_GLYPH_ORIENTATION
vertical_orientation
;
DWRITE_OPTICAL_ALIGNMENT
optical_alignment
;
DWRITE_LINE_SPACING
spacing
;
FLOAT
spacing
;
FLOAT
baseline
;
FLOAT
fontsize
;
DWRITE_TRIMMING
trimming
;
...
...
@@ -436,17 +434,16 @@ static inline HRESULT format_set_trimming(struct dwrite_textformat_data *format,
}
static
inline
HRESULT
format_set_linespacing
(
struct
dwrite_textformat_data
*
format
,
DWRITE_LINE_SPACING
_METHOD
method
,
FLOAT
spacing
,
FLOAT
baseline
,
BOOL
*
changed
)
DWRITE_LINE_SPACING
const
*
spacing
,
BOOL
*
changed
)
{
if
(
spacing
<
0
.
0
f
||
(
UINT32
)
method
>
DWRITE_LINE_SPACING_METHOD_UNIFORM
)
if
(
spacing
->
height
<
0
.
0
f
||
spacing
->
leadingBefore
<
0
.
0
f
||
spacing
->
leadingBefore
>
1
.
0
f
||
(
UINT32
)
spacing
->
method
>
DWRITE_LINE_SPACING_METHOD_PROPORTIONAL
)
return
E_INVALIDARG
;
if
(
changed
)
*
changed
=
format
->
spacingmethod
!=
method
||
format
->
spacing
!=
spacing
||
format
->
baseline
!=
baseline
;
if
(
changed
)
*
changed
=
memcmp
(
spacing
,
&
format
->
spacing
,
sizeof
(
*
spacing
))
;
format
->
spacingmethod
=
method
;
format
->
spacing
=
spacing
;
format
->
baseline
=
baseline
;
format
->
spacing
=
*
spacing
;
return
S_OK
;
}
...
...
@@ -3654,15 +3651,29 @@ static HRESULT WINAPI dwritetextlayout3_InvalidateLayout(IDWriteTextLayout3 *ifa
static
HRESULT
WINAPI
dwritetextlayout3_SetLineSpacing
(
IDWriteTextLayout3
*
iface
,
DWRITE_LINE_SPACING
const
*
spacing
)
{
struct
dwrite_textlayout
*
This
=
impl_from_IDWriteTextLayout3
(
iface
);
FIXME
(
"(%p)->(%p): stub
\n
"
,
This
,
spacing
);
return
E_NOTIMPL
;
BOOL
changed
;
HRESULT
hr
;
TRACE
(
"(%p)->(%p)
\n
"
,
This
,
spacing
);
hr
=
format_set_linespacing
(
&
This
->
format
,
spacing
,
&
changed
);
if
(
FAILED
(
hr
))
return
hr
;
if
(
changed
)
This
->
recompute
=
RECOMPUTE_EVERYTHING
;
return
S_OK
;
}
static
HRESULT
WINAPI
dwritetextlayout3_GetLineSpacing
(
IDWriteTextLayout3
*
iface
,
DWRITE_LINE_SPACING
*
spacing
)
{
struct
dwrite_textlayout
*
This
=
impl_from_IDWriteTextLayout3
(
iface
);
FIXME
(
"(%p)->(%p): stub
\n
"
,
This
,
spacing
);
return
E_NOTIMPL
;
TRACE
(
"(%p)->(%p)
\n
"
,
This
,
spacing
);
*
spacing
=
This
->
format
.
spacing
;
return
S_OK
;
}
static
HRESULT
WINAPI
dwritetextlayout3_GetLineMetrics
(
IDWriteTextLayout3
*
iface
,
DWRITE_LINE_METRICS1
*
metrics
,
...
...
@@ -3896,22 +3907,18 @@ static HRESULT WINAPI dwritetextformat_layout_SetTrimming(IDWriteTextFormat1 *if
}
static
HRESULT
WINAPI
dwritetextformat_layout_SetLineSpacing
(
IDWriteTextFormat1
*
iface
,
DWRITE_LINE_SPACING_METHOD
method
,
FLOAT
spacing
,
FLOAT
baseline
)
FLOAT
height
,
FLOAT
baseline
)
{
struct
dwrite_textlayout
*
This
=
impl_layout_from_IDWriteTextFormat1
(
iface
);
BOOL
changed
;
HRESULT
hr
;
DWRITE_LINE_SPACING
spacing
;
TRACE
(
"(%p)->(%d %f %f)
\n
"
,
This
,
method
,
spacing
,
baseline
);
TRACE
(
"(%p)->(%d %f %f)
\n
"
,
This
,
method
,
height
,
baseline
);
hr
=
format_set_linespacing
(
&
This
->
format
,
method
,
spacing
,
baseline
,
&
changed
);
if
(
FAILED
(
hr
))
return
hr
;
if
(
changed
)
This
->
recompute
=
RECOMPUTE_EVERYTHING
;
return
S_OK
;
spacing
=
This
->
format
.
spacing
;
spacing
.
method
=
method
;
spacing
.
height
=
height
;
spacing
.
baseline
=
baseline
;
return
IDWriteTextLayout3_SetLineSpacing
(
&
This
->
IDWriteTextLayout3_iface
,
&
spacing
);
}
static
DWRITE_TEXT_ALIGNMENT
WINAPI
dwritetextformat_layout_GetTextAlignment
(
IDWriteTextFormat1
*
iface
)
...
...
@@ -3977,9 +3984,9 @@ static HRESULT WINAPI dwritetextformat_layout_GetLineSpacing(IDWriteTextFormat1
TRACE
(
"(%p)->(%p %p %p)
\n
"
,
This
,
method
,
spacing
,
baseline
);
*
method
=
This
->
format
.
spacingmethod
;
*
spacing
=
This
->
format
.
spacing
;
*
baseline
=
This
->
format
.
baseline
;
*
method
=
This
->
format
.
spacing
.
method
;
*
spacing
=
This
->
format
.
spacing
.
height
;
*
baseline
=
This
->
format
.
spacing
.
baseline
;
return
S_OK
;
}
...
...
@@ -4462,8 +4469,10 @@ static HRESULT layout_format_from_textformat(struct dwrite_textlayout *layout, I
layout
->
format
.
readingdir
=
IDWriteTextFormat_GetReadingDirection
(
format
);
layout
->
format
.
flow
=
IDWriteTextFormat_GetFlowDirection
(
format
);
layout
->
format
.
fallback
=
NULL
;
hr
=
IDWriteTextFormat_GetLineSpacing
(
format
,
&
layout
->
format
.
spacingmethod
,
&
layout
->
format
.
spacing
,
&
layout
->
format
.
baseline
);
layout
->
format
.
spacing
.
leadingBefore
=
0
.
0
f
;
layout
->
format
.
spacing
.
fontLineGapUsage
=
DWRITE_FONT_LINE_GAP_USAGE_DEFAULT
;
hr
=
IDWriteTextFormat_GetLineSpacing
(
format
,
&
layout
->
format
.
spacing
.
method
,
&
layout
->
format
.
spacing
.
height
,
&
layout
->
format
.
spacing
.
baseline
);
if
(
FAILED
(
hr
))
return
hr
;
...
...
@@ -4495,9 +4504,17 @@ static HRESULT layout_format_from_textformat(struct dwrite_textlayout *layout, I
hr
=
IDWriteTextFormat_QueryInterface
(
format
,
&
IID_IDWriteTextFormat1
,
(
void
**
)
&
format1
);
if
(
hr
==
S_OK
)
{
IDWriteTextFormat2
*
format2
;
layout
->
format
.
vertical_orientation
=
IDWriteTextFormat1_GetVerticalGlyphOrientation
(
format1
);
layout
->
format
.
optical_alignment
=
IDWriteTextFormat1_GetOpticalAlignment
(
format1
);
IDWriteTextFormat1_GetFontFallback
(
format1
,
&
layout
->
format
.
fallback
);
if
(
IDWriteTextFormat1_QueryInterface
(
format1
,
&
IID_IDWriteTextFormat2
,
(
void
**
)
&
format2
)
==
S_OK
)
{
IDWriteTextFormat2_GetLineSpacing
(
format2
,
&
layout
->
format
.
spacing
);
IDWriteTextFormat2_Release
(
format2
);
}
IDWriteTextFormat1_Release
(
format1
);
}
else
{
...
...
@@ -4879,11 +4896,19 @@ static HRESULT WINAPI dwritetextformat_SetTrimming(IDWriteTextFormat2 *iface, DW
}
static
HRESULT
WINAPI
dwritetextformat_SetLineSpacing
(
IDWriteTextFormat2
*
iface
,
DWRITE_LINE_SPACING_METHOD
method
,
FLOAT
spacing
,
FLOAT
baseline
)
FLOAT
height
,
FLOAT
baseline
)
{
struct
dwrite_textformat
*
This
=
impl_from_IDWriteTextFormat2
(
iface
);
TRACE
(
"(%p)->(%d %f %f)
\n
"
,
This
,
method
,
spacing
,
baseline
);
return
format_set_linespacing
(
&
This
->
format
,
method
,
spacing
,
baseline
,
NULL
);
DWRITE_LINE_SPACING
spacing
;
TRACE
(
"(%p)->(%d %f %f)
\n
"
,
This
,
method
,
height
,
baseline
);
spacing
=
This
->
format
.
spacing
;
spacing
.
method
=
method
;
spacing
.
height
=
height
;
spacing
.
baseline
=
baseline
;
return
format_set_linespacing
(
&
This
->
format
,
&
spacing
,
NULL
);
}
static
DWRITE_TEXT_ALIGNMENT
WINAPI
dwritetextformat_GetTextAlignment
(
IDWriteTextFormat2
*
iface
)
...
...
@@ -4947,9 +4972,9 @@ static HRESULT WINAPI dwritetextformat_GetLineSpacing(IDWriteTextFormat2 *iface,
struct
dwrite_textformat
*
This
=
impl_from_IDWriteTextFormat2
(
iface
);
TRACE
(
"(%p)->(%p %p %p)
\n
"
,
This
,
method
,
spacing
,
baseline
);
*
method
=
This
->
format
.
spacingmethod
;
*
spacing
=
This
->
format
.
spacing
;
*
baseline
=
This
->
format
.
baseline
;
*
method
=
This
->
format
.
spacing
.
method
;
*
spacing
=
This
->
format
.
spacing
.
height
;
*
baseline
=
This
->
format
.
spacing
.
baseline
;
return
S_OK
;
}
...
...
@@ -5097,15 +5122,18 @@ static HRESULT WINAPI dwritetextformat1_GetFontFallback(IDWriteTextFormat2 *ifac
static
HRESULT
WINAPI
dwritetextformat2_SetLineSpacing
(
IDWriteTextFormat2
*
iface
,
DWRITE_LINE_SPACING
const
*
spacing
)
{
struct
dwrite_textformat
*
This
=
impl_from_IDWriteTextFormat2
(
iface
);
FIXME
(
"(%p)->(%p): stub
\n
"
,
This
,
spacing
);
return
E_NOTIMPL
;
TRACE
(
"(%p)->(%p)
\n
"
,
This
,
spacing
);
return
format_set_linespacing
(
&
This
->
format
,
spacing
,
NULL
)
;
}
static
HRESULT
WINAPI
dwritetextformat2_GetLineSpacing
(
IDWriteTextFormat2
*
iface
,
DWRITE_LINE_SPACING
*
spacing
)
{
struct
dwrite_textformat
*
This
=
impl_from_IDWriteTextFormat2
(
iface
);
FIXME
(
"(%p)->(%p): stub
\n
"
,
This
,
spacing
);
return
E_NOTIMPL
;
TRACE
(
"(%p)->(%p)
\n
"
,
This
,
spacing
);
*
spacing
=
This
->
format
.
spacing
;
return
S_OK
;
}
static
const
IDWriteTextFormat2Vtbl
dwritetextformatvtbl
=
{
...
...
@@ -5192,10 +5220,12 @@ HRESULT create_textformat(const WCHAR *family_name, IDWriteFontCollection *colle
This
->
format
.
last_line_wrapping
=
TRUE
;
This
->
format
.
readingdir
=
DWRITE_READING_DIRECTION_LEFT_TO_RIGHT
;
This
->
format
.
flow
=
DWRITE_FLOW_DIRECTION_TOP_TO_BOTTOM
;
This
->
format
.
spacingmethod
=
DWRITE_LINE_SPACING_METHOD_DEFAULT
;
This
->
format
.
spacing
.
method
=
DWRITE_LINE_SPACING_METHOD_DEFAULT
;
This
->
format
.
spacing
.
height
=
0
.
0
f
;
This
->
format
.
spacing
.
baseline
=
0
.
0
f
;
This
->
format
.
spacing
.
leadingBefore
=
0
.
0
f
;
This
->
format
.
spacing
.
fontLineGapUsage
=
DWRITE_FONT_LINE_GAP_USAGE_DEFAULT
;
This
->
format
.
vertical_orientation
=
DWRITE_VERTICAL_GLYPH_ORIENTATION_DEFAULT
;
This
->
format
.
spacing
=
0
.
0
f
;
This
->
format
.
baseline
=
0
.
0
f
;
This
->
format
.
trimming
.
granularity
=
DWRITE_TRIMMING_GRANULARITY_NONE
;
This
->
format
.
trimming
.
delimiter
=
0
;
This
->
format
.
trimming
.
delimiterCount
=
0
;
...
...
dlls/dwrite/tests/layout.c
View file @
9ec714db
...
...
@@ -1054,17 +1054,6 @@ if (0) /* crashes on native */
hr
=
IDWriteTextFormat_SetFlowDirection
(
format
,
DWRITE_FLOW_DIRECTION_TOP_TO_BOTTOM
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IDWriteTextFormat_SetLineSpacing
(
format
,
DWRITE_LINE_SPACING_METHOD_DEFAULT
,
0
.
0
,
0
.
0
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IDWriteTextFormat_SetLineSpacing
(
format
,
DWRITE_LINE_SPACING_METHOD_DEFAULT
,
0
.
0
,
-
10
.
0
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IDWriteTextFormat_SetLineSpacing
(
format
,
DWRITE_LINE_SPACING_METHOD_DEFAULT
,
-
10
.
0
,
0
.
0
);
ok
(
hr
==
E_INVALIDARG
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IDWriteTextFormat_SetLineSpacing
(
format
,
DWRITE_LINE_SPACING_METHOD_PROPORTIONAL
+
1
,
0
.
0
,
0
.
0
);
ok
(
hr
==
E_INVALIDARG
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IDWriteTextFormat_SetTrimming
(
format
,
&
trimming
,
NULL
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
...
...
@@ -5002,6 +4991,96 @@ static void test_InvalidateLayout(void)
IDWriteFactory_Release
(
factory
);
}
static
void
test_line_spacing
(
void
)
{
static
const
WCHAR
strW
[]
=
{
'a'
,
0
};
IDWriteTextFormat2
*
format2
;
IDWriteTextLayout
*
layout
;
IDWriteTextFormat
*
format
;
IDWriteFactory
*
factory
;
HRESULT
hr
;
factory
=
create_factory
();
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
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IDWriteTextFormat_SetLineSpacing
(
format
,
DWRITE_LINE_SPACING_METHOD_DEFAULT
,
0
.
0
f
,
0
.
0
f
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IDWriteTextFormat_SetLineSpacing
(
format
,
DWRITE_LINE_SPACING_METHOD_DEFAULT
,
0
.
0
f
,
-
10
.
0
f
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IDWriteTextFormat_SetLineSpacing
(
format
,
DWRITE_LINE_SPACING_METHOD_DEFAULT
,
-
10
.
0
f
,
0
.
0
f
);
ok
(
hr
==
E_INVALIDARG
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IDWriteTextFormat_SetLineSpacing
(
format
,
DWRITE_LINE_SPACING_METHOD_PROPORTIONAL
+
1
,
0
.
0
f
,
0
.
0
f
);
ok
(
hr
==
E_INVALIDARG
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IDWriteFactory_CreateTextLayout
(
factory
,
strW
,
1
,
format
,
1000
.
0
f
,
1000
.
0
f
,
&
layout
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IDWriteTextLayout_SetLineSpacing
(
layout
,
DWRITE_LINE_SPACING_METHOD_DEFAULT
,
0
.
0
f
,
0
.
0
f
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IDWriteTextLayout_SetLineSpacing
(
layout
,
DWRITE_LINE_SPACING_METHOD_DEFAULT
,
0
.
0
f
,
-
10
.
0
f
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IDWriteTextLayout_SetLineSpacing
(
layout
,
DWRITE_LINE_SPACING_METHOD_DEFAULT
,
-
10
.
0
f
,
0
.
0
f
);
ok
(
hr
==
E_INVALIDARG
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IDWriteTextLayout_SetLineSpacing
(
layout
,
DWRITE_LINE_SPACING_METHOD_PROPORTIONAL
+
1
,
0
.
0
f
,
0
.
0
f
);
ok
(
hr
==
E_INVALIDARG
,
"got 0x%08x
\n
"
,
hr
);
if
(
IDWriteTextFormat_QueryInterface
(
format
,
&
IID_IDWriteTextFormat2
,
(
void
**
)
&
format2
)
==
S_OK
)
{
DWRITE_LINE_SPACING
spacing
;
hr
=
IDWriteTextFormat2_GetLineSpacing
(
format2
,
&
spacing
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
ok
(
spacing
.
method
==
DWRITE_LINE_SPACING_METHOD_DEFAULT
,
"got method %d
\n
"
,
spacing
.
method
);
ok
(
spacing
.
height
==
0
.
0
f
,
"got %f
\n
"
,
spacing
.
height
);
ok
(
spacing
.
baseline
==
-
10
.
0
f
,
"got %f
\n
"
,
spacing
.
baseline
);
ok
(
spacing
.
leadingBefore
==
0
.
0
f
,
"got %f
\n
"
,
spacing
.
leadingBefore
);
ok
(
spacing
.
fontLineGapUsage
==
DWRITE_FONT_LINE_GAP_USAGE_DEFAULT
,
"got %f
\n
"
,
spacing
.
leadingBefore
);
spacing
.
leadingBefore
=
-
1
.
0
f
;
hr
=
IDWriteTextFormat2_SetLineSpacing
(
format2
,
&
spacing
);
ok
(
hr
==
E_INVALIDARG
,
"got 0x%08x
\n
"
,
hr
);
spacing
.
leadingBefore
=
1
.
1
f
;
hr
=
IDWriteTextFormat2_SetLineSpacing
(
format2
,
&
spacing
);
ok
(
hr
==
E_INVALIDARG
,
"got 0x%08x
\n
"
,
hr
);
spacing
.
leadingBefore
=
1
.
0
f
;
hr
=
IDWriteTextFormat2_SetLineSpacing
(
format2
,
&
spacing
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
spacing
.
method
=
DWRITE_LINE_SPACING_METHOD_PROPORTIONAL
+
1
;
hr
=
IDWriteTextFormat2_SetLineSpacing
(
format2
,
&
spacing
);
ok
(
hr
==
E_INVALIDARG
,
"got 0x%08x
\n
"
,
hr
);
spacing
.
method
=
DWRITE_LINE_SPACING_METHOD_PROPORTIONAL
;
spacing
.
fontLineGapUsage
=
DWRITE_FONT_LINE_GAP_USAGE_ENABLED
+
1
;
hr
=
IDWriteTextFormat2_SetLineSpacing
(
format2
,
&
spacing
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IDWriteTextFormat2_GetLineSpacing
(
format2
,
&
spacing
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
ok
(
spacing
.
fontLineGapUsage
==
DWRITE_FONT_LINE_GAP_USAGE_ENABLED
+
1
,
"got %d
\n
"
,
spacing
.
fontLineGapUsage
);
IDWriteTextFormat2_Release
(
format2
);
}
IDWriteTextLayout_Release
(
layout
);
IDWriteTextFormat_Release
(
format
);
IDWriteFactory_Release
(
factory
);
}
START_TEST
(
layout
)
{
IDWriteFactory
*
factory
;
...
...
@@ -5050,6 +5129,7 @@ START_TEST(layout)
test_SetOpticalAlignment
();
test_SetUnderline
();
test_InvalidateLayout
();
test_line_spacing
();
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