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
fd6e12af
Commit
fd6e12af
authored
Feb 23, 2017
by
Nikolay Sivov
Committed by
Alexandre Julliard
Feb 23, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dwrite/tests: Test runHeight underline attribute with all available fonts.
Signed-off-by:
Nikolay Sivov
<
nsivov@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
15b144b3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
162 additions
and
44 deletions
+162
-44
layout.c
dlls/dwrite/tests/layout.c
+162
-44
No files found.
dlls/dwrite/tests/layout.c
View file @
fd6e12af
/*
* Text layout/format tests
*
* Copyright 2012, 2014-201
6
Nikolay Sivov for CodeWeavers
* Copyright 2012, 2014-201
7
Nikolay Sivov for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
...
...
@@ -222,6 +222,46 @@ static void get_script_analysis(const WCHAR *str, UINT32 len, DWRITE_SCRIPT_ANAL
IDWriteFactory_Release
(
factory
);
}
static
IDWriteFontFace
*
get_fontface_from_format
(
IDWriteTextFormat
*
format
)
{
IDWriteFontCollection
*
collection
;
IDWriteFontFamily
*
family
;
IDWriteFontFace
*
fontface
;
IDWriteFont
*
font
;
WCHAR
nameW
[
255
];
UINT32
index
;
BOOL
exists
;
HRESULT
hr
;
hr
=
IDWriteTextFormat_GetFontCollection
(
format
,
&
collection
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IDWriteTextFormat_GetFontFamilyName
(
format
,
nameW
,
sizeof
(
nameW
)
/
sizeof
(
WCHAR
));
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IDWriteFontCollection_FindFamilyName
(
collection
,
nameW
,
&
index
,
&
exists
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IDWriteFontCollection_GetFontFamily
(
collection
,
index
,
&
family
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
IDWriteFontCollection_Release
(
collection
);
hr
=
IDWriteFontFamily_GetFirstMatchingFont
(
family
,
IDWriteTextFormat_GetFontWeight
(
format
),
IDWriteTextFormat_GetFontStretch
(
format
),
IDWriteTextFormat_GetFontStyle
(
format
),
&
font
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IDWriteFont_CreateFontFace
(
font
,
&
fontface
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
IDWriteFont_Release
(
font
);
IDWriteFontFamily_Release
(
family
);
return
fontface
;
}
#define EXPECT_REF(obj,ref) _expect_ref((IUnknown*)obj, ref, __LINE__)
static
void
_expect_ref
(
IUnknown
*
obj
,
ULONG
ref
,
int
line
)
{
...
...
@@ -447,6 +487,7 @@ struct renderer_context {
FLOAT
ppdip
;
FLOAT
originX
;
FLOAT
originY
;
IDWriteTextFormat
*
format
;
};
static
HRESULT
WINAPI
testrenderer_IsPixelSnappingDisabled
(
IDWriteTextRenderer
*
iface
,
...
...
@@ -555,6 +596,26 @@ static HRESULT WINAPI testrenderer_DrawUnderline(IDWriteTextRenderer *iface,
if
(
ctxt
)
TEST_MEASURING_MODE
(
ctxt
,
underline
->
measuringMode
);
todo_wine
ok
(
underline
->
runHeight
>
0
.
0
f
,
"Expected non-zero run height
\n
"
);
if
(
ctxt
&&
ctxt
->
format
)
{
DWRITE_FONT_METRICS
metrics
;
IDWriteFontFace
*
fontface
;
FLOAT
emsize
;
fontface
=
get_fontface_from_format
(
ctxt
->
format
);
emsize
=
IDWriteTextFormat_GetFontSize
(
ctxt
->
format
);
IDWriteFontFace_GetMetrics
(
fontface
,
&
metrics
);
ok
(
emsize
==
metrics
.
designUnitsPerEm
,
"Unexpected font size %f
\n
"
,
emsize
);
/* Expected height is in design units, allow some absolute difference from it. Seems to only happen on Vista */
todo_wine
ok
(
abs
(
metrics
.
capHeight
-
underline
->
runHeight
)
<
2
.
0
f
,
"Expected runHeight %u, got %f
\n
"
,
metrics
.
capHeight
,
underline
->
runHeight
);
IDWriteFontFace_Release
(
fontface
);
}
entry
.
kind
=
DRAW_UNDERLINE
;
if
(
effect
)
entry
.
kind
|=
DRAW_EFFECT
;
...
...
@@ -1506,8 +1567,7 @@ static void test_Draw(void)
factory
=
create_factory
();
ctxt
.
gdicompat
=
FALSE
;
ctxt
.
use_gdi_natural
=
FALSE
;
memset
(
&
ctxt
,
0
,
sizeof
(
ctxt
));
ctxt
.
snapping_disabled
=
TRUE
;
hr
=
IDWriteFactory_CreateTextFormat
(
factory
,
tahomaW
,
NULL
,
DWRITE_FONT_WEIGHT_BOLD
,
DWRITE_FONT_STYLE_NORMAL
,
...
...
@@ -3273,46 +3333,6 @@ static void test_SetDrawingEffect(void)
IDWriteFactory_Release
(
factory
);
}
static
IDWriteFontFace
*
get_fontface_from_format
(
IDWriteTextFormat
*
format
)
{
IDWriteFontCollection
*
collection
;
IDWriteFontFamily
*
family
;
IDWriteFontFace
*
fontface
;
IDWriteFont
*
font
;
WCHAR
nameW
[
255
];
UINT32
index
;
BOOL
exists
;
HRESULT
hr
;
hr
=
IDWriteTextFormat_GetFontCollection
(
format
,
&
collection
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IDWriteTextFormat_GetFontFamilyName
(
format
,
nameW
,
sizeof
(
nameW
)
/
sizeof
(
WCHAR
));
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IDWriteFontCollection_FindFamilyName
(
collection
,
nameW
,
&
index
,
&
exists
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IDWriteFontCollection_GetFontFamily
(
collection
,
index
,
&
family
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
IDWriteFontCollection_Release
(
collection
);
hr
=
IDWriteFontFamily_GetFirstMatchingFont
(
family
,
IDWriteTextFormat_GetFontWeight
(
format
),
IDWriteTextFormat_GetFontStretch
(
format
),
IDWriteTextFormat_GetFontStyle
(
format
),
&
font
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IDWriteFont_CreateFontFace
(
font
,
&
fontface
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
IDWriteFont_Release
(
font
);
IDWriteFontFamily_Release
(
family
);
return
fontface
;
}
static
BOOL
get_enus_string
(
IDWriteLocalizedStrings
*
strings
,
WCHAR
*
buff
,
UINT32
size
)
{
UINT32
index
;
...
...
@@ -4852,12 +4872,13 @@ static void test_SetUnderline(void)
{
static
const
WCHAR
encaW
[]
=
{
'e'
,
'n'
,
'-'
,
'C'
,
'A'
,
0
};
static
const
WCHAR
strW
[]
=
{
'a'
,
'e'
,
0x0300
,
'd'
,
0
};
/* accent grave */
IDWriteFontCollection
*
syscollection
;
DWRITE_CLUSTER_METRICS
clusters
[
4
];
IDWriteTextFormat
*
format
;
IDWriteTextLayout
*
layout
;
DWRITE_TEXT_RANGE
range
;
IDWriteFactory
*
factory
;
UINT32
count
;
UINT32
count
,
i
;
HRESULT
hr
;
factory
=
create_factory
();
...
...
@@ -4948,6 +4969,103 @@ todo_wine
IDWriteTextLayout_Release
(
layout
);
IDWriteTextFormat_Release
(
format
);
/* Test runHeight value with all available fonts */
hr
=
IDWriteFactory_GetSystemFontCollection
(
factory
,
&
syscollection
,
FALSE
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
count
=
IDWriteFontCollection_GetFontFamilyCount
(
syscollection
);
for
(
i
=
0
;
i
<
count
;
i
++
)
{
DWRITE_FONT_METRICS
fontmetrics
;
IDWriteLocalizedStrings
*
names
;
struct
renderer_context
ctxt
;
IDWriteFontFamily
*
family
;
IDWriteFontFace
*
fontface
;
IDWriteFont
*
font
;
WCHAR
nameW
[
256
];
BOOL
exists
;
format
=
NULL
;
layout
=
NULL
;
hr
=
IDWriteFontCollection_GetFontFamily
(
syscollection
,
i
,
&
family
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IDWriteFontFamily_GetFirstMatchingFont
(
family
,
DWRITE_FONT_WEIGHT_NORMAL
,
DWRITE_FONT_STRETCH_NORMAL
,
DWRITE_FONT_STYLE_NORMAL
,
&
font
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IDWriteFont_CreateFontFace
(
font
,
&
fontface
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IDWriteFontFamily_GetFamilyNames
(
family
,
&
names
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
if
(
!
(
exists
=
get_enus_string
(
names
,
nameW
,
sizeof
(
nameW
)
/
sizeof
(
nameW
[
0
]))))
{
IDWriteLocalFontFileLoader
*
localloader
;
IDWriteFontFileLoader
*
loader
;
IDWriteFontFile
*
file
;
const
void
*
key
;
UINT32
keysize
;
UINT32
count
;
count
=
1
;
hr
=
IDWriteFontFace_GetFiles
(
fontface
,
&
count
,
&
file
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IDWriteFontFile_GetLoader
(
file
,
&
loader
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IDWriteFontFileLoader_QueryInterface
(
loader
,
&
IID_IDWriteLocalFontFileLoader
,
(
void
**
)
&
localloader
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
IDWriteFontFileLoader_Release
(
loader
);
hr
=
IDWriteFontFile_GetReferenceKey
(
file
,
&
key
,
&
keysize
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IDWriteLocalFontFileLoader_GetFilePathFromKey
(
localloader
,
key
,
keysize
,
nameW
,
sizeof
(
nameW
)
/
sizeof
(
*
nameW
));
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
skip
(
"Failed to get English family name, font file %s
\n
"
,
wine_dbgstr_w
(
nameW
));
IDWriteLocalFontFileLoader_Release
(
localloader
);
IDWriteFontFile_Release
(
file
);
}
IDWriteLocalizedStrings_Release
(
names
);
IDWriteFont_Release
(
font
);
if
(
!
exists
)
goto
cleanup
;
IDWriteFontFace_GetMetrics
(
fontface
,
&
fontmetrics
);
hr
=
IDWriteFactory_CreateTextFormat
(
factory
,
nameW
,
NULL
,
DWRITE_FONT_WEIGHT_NORMAL
,
DWRITE_FONT_STYLE_NORMAL
,
DWRITE_FONT_STRETCH_NORMAL
,
fontmetrics
.
designUnitsPerEm
,
enusW
,
&
format
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IDWriteFactory_CreateTextLayout
(
factory
,
strW
,
2
,
format
,
30000
.
0
f
,
100
.
0
f
,
&
layout
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
range
.
startPosition
=
0
;
range
.
length
=
2
;
hr
=
IDWriteTextLayout_SetUnderline
(
layout
,
TRUE
,
range
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
memset
(
&
ctxt
,
0
,
sizeof
(
ctxt
));
ctxt
.
format
=
format
;
hr
=
IDWriteTextLayout_Draw
(
layout
,
&
ctxt
,
&
testrenderer
,
0
.
0
f
,
0
.
0
f
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
cleanup:
if
(
layout
)
IDWriteTextLayout_Release
(
layout
);
if
(
format
)
IDWriteTextFormat_Release
(
format
);
IDWriteFontFace_Release
(
fontface
);
IDWriteFontFamily_Release
(
family
);
}
IDWriteFontCollection_Release
(
syscollection
);
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