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
0879b767
Commit
0879b767
authored
Apr 01, 2009
by
Vincent Povirk
Committed by
Alexandre Julliard
Apr 02, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gdiplus: GdipDrawString: Handle either a width or height of 0 sanely.
Based on Aric's recent patch.
parent
9993b0a0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
73 additions
and
6 deletions
+73
-6
graphics.c
dlls/gdiplus/graphics.c
+21
-6
graphics.c
dlls/gdiplus/tests/graphics.c
+52
-0
No files found.
dlls/gdiplus/graphics.c
View file @
0879b767
...
...
@@ -2011,20 +2011,35 @@ GpStatus WINGDIPAPI GdipDrawString(GpGraphics *graphics, GDIPCONST WCHAR *string
rectcpy
[
3
].
Y
=
rectcpy
[
2
].
Y
=
rect
->
Y
+
rect
->
Height
;
transform_and_round_points
(
graphics
,
corners
,
rectcpy
,
4
);
if
(
roundr
(
rect
->
Width
)
==
0
&&
roundr
(
rect
->
Height
)
==
0
){
rel_width
=
rel_height
=
1
.
0
;
nwidth
=
nheight
=
INT_MAX
;
if
(
roundr
(
rect
->
Width
)
==
0
)
{
rel_width
=
1
.
0
;
nwidth
=
INT_MAX
;
}
else
{
else
{
rel_width
=
sqrt
((
corners
[
1
].
x
-
corners
[
0
].
x
)
*
(
corners
[
1
].
x
-
corners
[
0
].
x
)
+
(
corners
[
1
].
y
-
corners
[
0
].
y
)
*
(
corners
[
1
].
y
-
corners
[
0
].
y
))
/
rect
->
Width
;
nwidth
=
roundr
(
rel_width
*
rect
->
Width
);
}
if
(
roundr
(
rect
->
Height
)
==
0
)
{
rel_height
=
1
.
0
;
nheight
=
INT_MAX
;
}
else
{
rel_height
=
sqrt
((
corners
[
2
].
x
-
corners
[
1
].
x
)
*
(
corners
[
2
].
x
-
corners
[
1
].
x
)
+
(
corners
[
2
].
y
-
corners
[
1
].
y
)
*
(
corners
[
2
].
y
-
corners
[
1
].
y
))
/
rect
->
Height
;
nwidth
=
roundr
(
rel_width
*
rect
->
Width
);
nheight
=
roundr
(
rel_height
*
rect
->
Height
);
}
if
(
roundr
(
rect
->
Width
)
!=
0
&&
roundr
(
rect
->
Height
)
!=
0
)
{
/* FIXME: If only the width or only the height is 0, we should probably still clip */
rgn
=
CreatePolygonRgn
(
corners
,
4
,
ALTERNATE
);
SelectClipRgn
(
graphics
->
hdc
,
rgn
);
}
...
...
dlls/gdiplus/tests/graphics.c
View file @
0879b767
...
...
@@ -935,6 +935,57 @@ static void test_textcontrast(void)
ReleaseDC
(
0
,
hdc
);
}
static
void
test_GdipDrawString
(
void
)
{
GpStatus
status
;
GpGraphics
*
graphics
=
NULL
;
GpFont
*
fnt
=
NULL
;
RectF
rect
;
GpStringFormat
*
format
;
GpBrush
*
brush
;
LOGFONTA
logfont
;
HDC
hdc
=
GetDC
(
0
);
static
const
WCHAR
string
[]
=
{
'T'
,
'e'
,
's'
,
't'
,
0
};
memset
(
&
logfont
,
0
,
sizeof
(
logfont
));
strcpy
(
logfont
.
lfFaceName
,
"Arial"
);
logfont
.
lfHeight
=
12
;
logfont
.
lfCharSet
=
DEFAULT_CHARSET
;
status
=
GdipCreateFromHDC
(
hdc
,
&
graphics
);
expect
(
Ok
,
status
);
status
=
GdipCreateFontFromLogfontA
(
hdc
,
&
logfont
,
&
fnt
);
if
(
status
==
FileNotFound
)
{
skip
(
"Arial not installed.
\n
"
);
return
;
}
expect
(
Ok
,
status
);
status
=
GdipCreateSolidFill
((
ARGB
)
0xdeadbeef
,
(
GpSolidFill
**
)
&
brush
);
expect
(
Ok
,
status
);
status
=
GdipCreateStringFormat
(
0
,
0
,
&
format
);
expect
(
Ok
,
status
);
rect
.
X
=
0
;
rect
.
Y
=
0
;
rect
.
Width
=
0
;
rect
.
Height
=
12
;
status
=
GdipDrawString
(
graphics
,
string
,
4
,
fnt
,
&
rect
,
format
,
brush
);
expect
(
Ok
,
status
);
GdipDeleteGraphics
(
graphics
);
GdipDeleteBrush
(
brush
);
GdipDeleteFont
(
fnt
);
GdipDeleteStringFormat
(
format
);
ReleaseDC
(
0
,
hdc
);
}
START_TEST
(
graphics
)
{
struct
GdiplusStartupInput
gdiplusStartupInput
;
...
...
@@ -954,6 +1005,7 @@ START_TEST(graphics)
test_GdipDrawArcI
();
test_GdipDrawLineI
();
test_GdipDrawLinesI
();
test_GdipDrawString
();
test_Get_Release_DC
();
test_transformpoints
();
test_get_set_clip
();
...
...
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