Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
wine
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lorenzo Ferrillo
wine
Commits
50931d89
Commit
50931d89
authored
12 years ago
by
Dmitry Timoshkov
Committed by
Alexandre Julliard
12 years ago
Browse files
Options
Downloads
Patches
Plain Diff
gdiplus: Add a test for font height scaling.
parent
6bb35385
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dlls/gdiplus/tests/graphics.c
+98
-0
98 additions, 0 deletions
dlls/gdiplus/tests/graphics.c
with
98 additions
and
0 deletions
dlls/gdiplus/tests/graphics.c
+
98
−
0
View file @
50931d89
...
...
@@ -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
)
{
struct
GdiplusStartupInput
gdiplusStartupInput
;
...
...
@@ -3700,6 +3797,7 @@ START_TEST(graphics)
GdiplusStartup
(
&
gdiplusToken
,
&
gdiplusStartupInput
,
NULL
);
test_font_height_scaling
();
test_transform
();
test_GdipMeasureString
();
test_constructor_destructor
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment