Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
50931d89
Commit
50931d89
authored
Aug 15, 2012
by
Dmitry Timoshkov
Committed by
Alexandre Julliard
Aug 15, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gdiplus: Add a test for font height scaling.
parent
6bb35385
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
98 additions
and
0 deletions
+98
-0
graphics.c
dlls/gdiplus/tests/graphics.c
+98
-0
No files found.
dlls/gdiplus/tests/graphics.c
View file @
50931d89
...
@@ -3674,6 +3674,103 @@ static void test_transform(void)
...
@@ -3674,6 +3674,103 @@ static void test_transform(void)
}
}
}
}
/* Many people on the net ask why there is so much difference in rendered
* text height between gdiplus and gdi32, this test suggests an answer to
* that question. Important: this test assumes that font dpi == device dpi.
*/
static
void
test_font_height_scaling
(
void
)
{
static
const
WCHAR
tahomaW
[]
=
{
'T'
,
'a'
,
'h'
,
'o'
,
'm'
,
'a'
,
0
};
static
const
WCHAR
string
[]
=
{
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
0
};
HDC
hdc
;
GpStringFormat
*
format
;
GpGraphics
*
graphics
;
GpFontFamily
*
family
;
GpFont
*
font
;
GpStatus
status
;
RectF
bounds
,
rect
;
REAL
height
,
dpi
;
PointF
ptf
;
GpUnit
gfx_unit
,
font_unit
;
status
=
GdipCreateStringFormat
(
0
,
LANG_NEUTRAL
,
&
format
);
expect
(
Ok
,
status
);
status
=
GdipCreateFontFamilyFromName
(
tahomaW
,
NULL
,
&
family
);
expect
(
Ok
,
status
);
hdc
=
CreateCompatibleDC
(
0
);
status
=
GdipCreateFromHDC
(
hdc
,
&
graphics
);
status
=
GdipGetDpiY
(
graphics
,
&
dpi
);
expect
(
Ok
,
status
);
/* UnitPixel = 2, UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
/* UnitPixel as a font base unit is not tested because it drastically
differs in behaviour */
for
(
font_unit
=
3
;
font_unit
<=
6
;
font_unit
++
)
{
/* There is a bug somewhere in native gdiplus that leads
* to extra conversion from points to pixels, so in order
* to get a 100 pixel text height it's needed to convert
* 100 pixels to points, and only then convert the result
* to desired units. The scale factor is 1.333333 at 96 dpi!
* Perhaps an implementor took name of GdipTransformPoints
* directly and assumed that it takes value in *points*?
*/
status
=
GdipSetPageUnit
(
graphics
,
UnitPoint
);
expect
(
Ok
,
status
);
ptf
.
X
=
0
;
ptf
.
Y
=
100
.
0
;
status
=
GdipTransformPoints
(
graphics
,
CoordinateSpaceWorld
,
CoordinateSpaceDevice
,
&
ptf
,
1
);
expect
(
Ok
,
status
);
trace
(
"100.0 pixels, %.1f dpi => %f points
\n
"
,
dpi
,
ptf
.
Y
);
status
=
GdipSetPageUnit
(
graphics
,
font_unit
);
expect
(
Ok
,
status
);
status
=
GdipTransformPoints
(
graphics
,
CoordinateSpaceWorld
,
CoordinateSpaceDevice
,
&
ptf
,
1
);
expect
(
Ok
,
status
);
height
=
ptf
.
Y
;
trace
(
"height %f units
\n
"
,
height
);
status
=
GdipCreateFont
(
family
,
height
,
FontStyleRegular
,
font_unit
,
&
font
);
expect
(
Ok
,
status
);
/* UnitPixel = 2, UnitPoint = 3, UnitInch = 4, UnitDocument = 5, UnitMillimeter = 6 */
for
(
gfx_unit
=
2
;
gfx_unit
<=
6
;
gfx_unit
++
)
{
int
match
;
status
=
GdipSetPageUnit
(
graphics
,
gfx_unit
);
expect
(
Ok
,
status
);
rect
.
X
=
0
.
0
;
rect
.
Y
=
0
.
0
;
rect
.
Width
=
0
;
rect
.
Height
=
0
;
bounds
.
X
=
0
.
0
;
bounds
.
Y
=
0
.
0
;
bounds
.
Width
=
0
;
bounds
.
Height
=
0
;
status
=
GdipMeasureString
(
graphics
,
string
,
-
1
,
font
,
&
rect
,
format
,
&
bounds
,
NULL
,
NULL
);
expect
(
Ok
,
status
);
ptf
.
X
=
0
;
ptf
.
Y
=
bounds
.
Height
;
status
=
GdipTransformPoints
(
graphics
,
CoordinateSpaceDevice
,
CoordinateSpaceWorld
,
&
ptf
,
1
);
expect
(
Ok
,
status
);
match
=
fabs
(
100
.
0
-
ptf
.
Y
)
<=
1
.
0
;
ok
(
match
||
broken
(
!
match
)
/* before win7 */
,
"Expected 100.0, got %f
\n
"
,
ptf
.
Y
);
/* verify the result */
ptf
.
Y
=
units_to_pixels
(
bounds
.
Height
,
gfx_unit
,
dpi
);
match
=
fabs
(
100
.
0
-
ptf
.
Y
)
<=
1
.
1
;
ok
(
match
||
broken
(
!
match
)
/* before win7 */
,
"Expected 100.0, got %f
\n
"
,
ptf
.
Y
);
}
}
status
=
GdipDeleteGraphics
(
graphics
);
expect
(
Ok
,
status
);
DeleteDC
(
hdc
);
}
START_TEST
(
graphics
)
START_TEST
(
graphics
)
{
{
struct
GdiplusStartupInput
gdiplusStartupInput
;
struct
GdiplusStartupInput
gdiplusStartupInput
;
...
@@ -3700,6 +3797,7 @@ START_TEST(graphics)
...
@@ -3700,6 +3797,7 @@ START_TEST(graphics)
GdiplusStartup
(
&
gdiplusToken
,
&
gdiplusStartupInput
,
NULL
);
GdiplusStartup
(
&
gdiplusToken
,
&
gdiplusStartupInput
,
NULL
);
test_font_height_scaling
();
test_transform
();
test_transform
();
test_GdipMeasureString
();
test_GdipMeasureString
();
test_constructor_destructor
();
test_constructor_destructor
();
...
...
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