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
351e5831
Commit
351e5831
authored
Dec 11, 2012
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gdi32: Fix text justification to properly handle logical coordinates.
parent
91ebca2b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
23 deletions
+43
-23
font.c
dlls/gdi32/font.c
+6
-7
dc.c
dlls/gdi32/tests/dc.c
+13
-0
font.c
dlls/gdi32/tests/font.c
+24
-16
No files found.
dlls/gdi32/font.c
View file @
351e5831
...
...
@@ -1189,7 +1189,7 @@ BOOL WINAPI GetTextExtentExPointW( HDC hdc, LPCWSTR str, INT count,
/* Perform device size to world size transformations. */
if
(
ret
)
{
INT
extra
=
dc
->
charExtra
,
INT
extra
=
abs
(
INTERNAL_XWSTODS
(
dc
,
dc
->
charExtra
))
,
breakExtra
=
dc
->
breakExtra
,
breakRem
=
dc
->
breakRem
,
i
;
...
...
@@ -1198,7 +1198,6 @@ BOOL WINAPI GetTextExtentExPointW( HDC hdc, LPCWSTR str, INT count,
{
for
(
i
=
0
;
i
<
count
;
++
i
)
{
dxs
[
i
]
=
abs
(
INTERNAL_XDSTOWS
(
dc
,
dxs
[
i
]));
dxs
[
i
]
+=
(
i
+
1
)
*
extra
;
if
(
count
>
1
&&
(
breakExtra
||
breakRem
)
&&
str
[
i
]
==
tm
.
tmBreakChar
)
{
...
...
@@ -1209,15 +1208,12 @@ BOOL WINAPI GetTextExtentExPointW( HDC hdc, LPCWSTR str, INT count,
dxs
[
i
]
++
;
}
}
dxs
[
i
]
=
abs
(
INTERNAL_XDSTOWS
(
dc
,
dxs
[
i
]));
if
(
dxs
[
i
]
<=
maxExt
)
++
nFit
;
}
breakRem
=
dc
->
breakRem
;
}
size
->
cx
=
abs
(
INTERNAL_XDSTOWS
(
dc
,
size
->
cx
));
size
->
cy
=
abs
(
INTERNAL_YDSTOWS
(
dc
,
size
->
cy
));
if
(
!
dxs
&&
count
>
1
&&
(
breakExtra
||
breakRem
))
else
if
(
count
>
1
&&
(
breakExtra
||
breakRem
))
{
for
(
i
=
0
;
i
<
count
;
i
++
)
{
...
...
@@ -1232,6 +1228,9 @@ BOOL WINAPI GetTextExtentExPointW( HDC hdc, LPCWSTR str, INT count,
}
}
}
size
->
cx
+=
count
*
extra
;
size
->
cx
=
abs
(
INTERNAL_XDSTOWS
(
dc
,
size
->
cx
));
size
->
cy
=
abs
(
INTERNAL_YDSTOWS
(
dc
,
size
->
cy
));
}
if
(
lpnFit
)
...
...
dlls/gdi32/tests/dc.c
View file @
351e5831
...
...
@@ -58,6 +58,7 @@ static void test_dc_values(void)
{
HDC
hdc
=
CreateDCA
(
"DISPLAY"
,
NULL
,
NULL
,
NULL
);
COLORREF
color
;
int
extra
;
ok
(
hdc
!=
NULL
,
"CreateDC failed
\n
"
);
color
=
SetBkColor
(
hdc
,
0x12345678
);
...
...
@@ -86,6 +87,18 @@ static void test_dc_values(void)
color
=
GetTextColor
(
hdc
);
ok
(
color
==
0
,
"wrong color %08x
\n
"
,
color
);
extra
=
GetTextCharacterExtra
(
hdc
);
ok
(
extra
==
0
,
"initial extra %d
\n
"
,
extra
);
SetTextCharacterExtra
(
hdc
,
123
);
extra
=
GetTextCharacterExtra
(
hdc
);
ok
(
extra
==
123
,
"initial extra %d
\n
"
,
extra
);
SetMapMode
(
hdc
,
MM_LOMETRIC
);
extra
=
GetTextCharacterExtra
(
hdc
);
ok
(
extra
==
123
,
"initial extra %d
\n
"
,
extra
);
SetMapMode
(
hdc
,
MM_TEXT
);
extra
=
GetTextCharacterExtra
(
hdc
);
ok
(
extra
==
123
,
"initial extra %d
\n
"
,
extra
);
DeleteDC
(
hdc
);
}
...
...
dlls/gdi32/tests/font.c
View file @
351e5831
...
...
@@ -1753,18 +1753,17 @@ static void testJustification(HDC hdc, PSTR str, RECT *clientArea)
{
INT
y
,
breakCount
,
justifiedWidth
=
0
,
/* to test GetTextExtentExPointW() */
areaWidth
=
clientArea
->
right
-
clientArea
->
left
,
nErrors
=
0
,
e
;
BOOL
lastExtent
=
FALSE
;
PSTR
pFirstChar
,
pLastChar
;
SIZE
size
;
TEXTMETRICA
tm
;
struct
err
{
char
extent
[
100
];
char
*
start
;
int
len
;
int
GetTextExtentExPointWWidth
;
}
error
[
1
0
];
}
error
[
2
0
];
GetTextMetricsA
(
hdc
,
&
tm
);
y
=
clientArea
->
top
;
...
...
@@ -1803,18 +1802,16 @@ static void testJustification(HDC hdc, PSTR str, RECT *clientArea)
{
SetTextJustification
(
hdc
,
areaWidth
-
size
.
cx
,
breakCount
);
GetTextExtentPoint32
(
hdc
,
pFirstChar
,
pLastChar
-
pFirstChar
,
&
size
);
justifiedWidth
=
size
.
cx
;
if
(
size
.
cx
!=
areaWidth
&&
nErrors
<
sizeof
(
error
)
/
sizeof
(
error
[
0
])
-
1
)
{
error
[
nErrors
].
start
=
pFirstChar
;
error
[
nErrors
].
len
=
pLastChar
-
pFirstChar
;
error
[
nErrors
].
GetTextExtentExPointWWidth
=
size
.
cx
;
nErrors
++
;
}
}
else
lastExtent
=
TRUE
;
/* catch errors and report them */
if
(
!
lastExtent
&&
(
justifiedWidth
!=
areaWidth
))
{
memset
(
error
[
nErrors
].
extent
,
0
,
100
);
memcpy
(
error
[
nErrors
].
extent
,
pFirstChar
,
pLastChar
-
pFirstChar
);
error
[
nErrors
].
GetTextExtentExPointWWidth
=
justifiedWidth
;
nErrors
++
;
}
trace
(
"%u %.*s
\n
"
,
size
.
cx
,
(
int
)(
pLastChar
-
pFirstChar
),
pFirstChar
);
y
+=
size
.
cy
;
str
=
pLastChar
;
...
...
@@ -1825,8 +1822,8 @@ static void testJustification(HDC hdc, PSTR str, RECT *clientArea)
/* The width returned by GetTextExtentPoint32() is exactly the same
returned by GetTextExtentExPointW() - see dlls/gdi32/font.c */
ok
(
error
[
e
].
GetTextExtentExPointWWidth
==
areaWidth
,
"GetTextExtentPointW() for
\"
%s
\"
should have returned a width of %d, not %d.
\n
"
,
error
[
e
].
exten
t
,
areaWidth
,
error
[
e
].
GetTextExtentExPointWWidth
);
"GetTextExtentPointW() for
\"
%
.*
s
\"
should have returned a width of %d, not %d.
\n
"
,
error
[
e
].
len
,
error
[
e
].
star
t
,
areaWidth
,
error
[
e
].
GetTextExtentExPointWWidth
);
}
}
...
...
@@ -1862,6 +1859,17 @@ static void test_SetTextJustification(void)
testJustification
(
hdc
,
testText
,
&
clientArea
);
SetMapMode
(
hdc
,
MM_ANISOTROPIC
);
SetWindowExtEx
(
hdc
,
2
,
2
,
NULL
);
GetClientRect
(
hwnd
,
&
clientArea
);
DPtoLP
(
hdc
,
(
POINT
*
)
&
clientArea
,
2
);
testJustification
(
hdc
,
testText
,
&
clientArea
);
SetViewportExtEx
(
hdc
,
3
,
3
,
NULL
);
GetClientRect
(
hwnd
,
&
clientArea
);
DPtoLP
(
hdc
,
(
POINT
*
)
&
clientArea
,
2
);
testJustification
(
hdc
,
testText
,
&
clientArea
);
DeleteObject
(
hfont
);
ReleaseDC
(
hwnd
,
hdc
);
DestroyWindow
(
hwnd
);
...
...
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