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
Zsolt Vadász
wine
Commits
3aab64de
Commit
3aab64de
authored
20 years ago
by
Dmitry Timoshkov
Committed by
Alexandre Julliard
20 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Added a test showing how GDI scales bitmap font metrics.
parent
26e61684
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/gdi/tests/gdiobj.c
+134
-0
134 additions, 0 deletions
dlls/gdi/tests/gdiobj.c
with
134 additions
and
0 deletions
dlls/gdi/tests/gdiobj.c
+
134
−
0
View file @
3aab64de
...
...
@@ -2,6 +2,7 @@
* Unit test suite for GDI objects
*
* Copyright 2002 Mike McCormack
* Copyright 2004 Dmitry Timoshkov
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
...
...
@@ -72,7 +73,140 @@ static void test_logfont(void)
DeleteObject
(
hfont
);
}
static
INT
CALLBACK
font_enum_proc
(
const
LOGFONT
*
elf
,
const
TEXTMETRIC
*
ntm
,
DWORD
type
,
LPARAM
lParam
)
{
if
(
type
&
RASTER_FONTTYPE
)
{
LOGFONT
*
lf
=
(
LOGFONT
*
)
lParam
;
*
lf
=
*
elf
;
return
0
;
/* stop enumeration */
}
return
1
;
/* continue enumeration */
}
static
void
test_font_metrics
(
HDC
hdc
,
HFONT
hfont
,
const
char
*
test_str
,
INT
test_str_len
,
const
TEXTMETRICA
*
tm_orig
,
const
SIZE
*
size_orig
,
INT
width_orig
,
INT
scale_x
,
INT
scale_y
)
{
HFONT
old_hfont
;
TEXTMETRICA
tm
;
SIZE
size
;
INT
width
;
old_hfont
=
SelectObject
(
hdc
,
hfont
);
GetTextMetricsA
(
hdc
,
&
tm
);
ok
(
tm
.
tmHeight
==
tm_orig
->
tmHeight
*
scale_y
,
"%ld != %ld
\n
"
,
tm
.
tmHeight
,
tm_orig
->
tmHeight
*
scale_y
);
ok
(
tm
.
tmAscent
==
tm_orig
->
tmAscent
*
scale_y
,
"%ld != %ld
\n
"
,
tm
.
tmAscent
,
tm_orig
->
tmAscent
*
scale_y
);
ok
(
tm
.
tmDescent
==
tm_orig
->
tmDescent
*
scale_y
,
"%ld != %ld
\n
"
,
tm
.
tmDescent
,
tm_orig
->
tmDescent
*
scale_y
);
ok
(
tm
.
tmAveCharWidth
==
tm_orig
->
tmAveCharWidth
*
scale_x
,
"%ld != %ld
\n
"
,
tm
.
tmAveCharWidth
,
tm_orig
->
tmAveCharWidth
*
scale_x
);
GetTextExtentPoint32A
(
hdc
,
test_str
,
test_str_len
,
&
size
);
ok
(
size
.
cx
==
size_orig
->
cx
*
scale_x
,
"%ld != %ld
\n
"
,
size
.
cx
,
size_orig
->
cx
*
scale_x
);
ok
(
size
.
cy
==
size_orig
->
cy
*
scale_y
,
"%ld != %ld
\n
"
,
size
.
cy
,
size_orig
->
cy
*
scale_y
);
GetCharWidthA
(
hdc
,
'A'
,
'A'
,
&
width
);
ok
(
width
==
width_orig
*
scale_x
,
"%d != %d
\n
"
,
width
,
width_orig
*
scale_x
);
SelectObject
(
hdc
,
old_hfont
);
}
/* see whether GDI scales bitmap font metrics */
static
void
test_bitmap_font
(
void
)
{
static
const
char
test_str
[
11
]
=
"Test String"
;
HDC
hdc
;
LOGFONTA
bitmap_lf
,
lf
;
HFONT
hfont
,
old_hfont
;
TEXTMETRICA
tm_orig
;
SIZE
size_orig
;
INT
ret
,
i
,
width_orig
,
height_orig
;
hdc
=
GetDC
(
0
);
/* "System" has only 1 pixel size defined, otherwise the test breaks */
ret
=
EnumFontFamiliesA
(
hdc
,
"System"
,
font_enum_proc
,
(
LPARAM
)
&
bitmap_lf
);
if
(
ret
)
{
ReleaseDC
(
0
,
hdc
);
trace
(
"no bitmap fonts were found, skipping the test
\n
"
);
return
;
}
trace
(
"found bitmap font %s, height %ld
\n
"
,
bitmap_lf
.
lfFaceName
,
bitmap_lf
.
lfHeight
);
height_orig
=
bitmap_lf
.
lfHeight
;
hfont
=
CreateFontIndirectA
(
&
bitmap_lf
);
assert
(
hfont
);
old_hfont
=
SelectObject
(
hdc
,
hfont
);
ok
(
GetTextMetricsA
(
hdc
,
&
tm_orig
),
"GetTextMetricsA failed
\n
"
);
ok
(
GetTextExtentPoint32A
(
hdc
,
test_str
,
sizeof
(
test_str
),
&
size_orig
),
"GetTextExtentPoint32A failed
\n
"
);
ok
(
GetCharWidthA
(
hdc
,
'A'
,
'A'
,
&
width_orig
),
"GetCharWidthA failed
\n
"
);
SelectObject
(
hdc
,
old_hfont
);
DeleteObject
(
hfont
);
/* test fractional scaling */
for
(
i
=
1
;
i
<
height_orig
;
i
++
)
{
bitmap_lf
.
lfHeight
=
i
;
hfont
=
CreateFontIndirectA
(
&
bitmap_lf
);
assert
(
hfont
);
ret
=
GetObject
(
hfont
,
sizeof
(
lf
),
&
lf
);
ok
(
ret
==
sizeof
(
lf
),
"GetObject failed: %d
\n
"
,
ret
);
ok
(
!
memcmp
(
&
bitmap_lf
,
&
lf
,
FIELD_OFFSET
(
LOGFONTA
,
lfFaceName
)),
"fonts don't match
\n
"
);
ok
(
!
lstrcmpA
(
bitmap_lf
.
lfFaceName
,
lf
.
lfFaceName
),
"font names don't match: %s != %s
\n
"
,
bitmap_lf
.
lfFaceName
,
lf
.
lfFaceName
);
test_font_metrics
(
hdc
,
hfont
,
test_str
,
sizeof
(
test_str
),
&
tm_orig
,
&
size_orig
,
width_orig
,
1
,
1
);
DeleteObject
(
hfont
);
}
/* test integer scaling 3x2 */
bitmap_lf
.
lfHeight
=
height_orig
*
2
;
bitmap_lf
.
lfWidth
*=
3
;
hfont
=
CreateFontIndirectA
(
&
bitmap_lf
);
assert
(
hfont
);
ret
=
GetObject
(
hfont
,
sizeof
(
lf
),
&
lf
);
ok
(
ret
==
sizeof
(
lf
),
"GetObject failed: %d
\n
"
,
ret
);
ok
(
!
memcmp
(
&
bitmap_lf
,
&
lf
,
FIELD_OFFSET
(
LOGFONTA
,
lfFaceName
)),
"fonts don't match
\n
"
);
ok
(
!
lstrcmpA
(
bitmap_lf
.
lfFaceName
,
lf
.
lfFaceName
),
"font names don't match: %s != %s
\n
"
,
bitmap_lf
.
lfFaceName
,
lf
.
lfFaceName
);
todo_wine
{
test_font_metrics
(
hdc
,
hfont
,
test_str
,
sizeof
(
test_str
),
&
tm_orig
,
&
size_orig
,
width_orig
,
3
,
2
);
}
DeleteObject
(
hfont
);
/* test integer scaling 3x3 */
bitmap_lf
.
lfHeight
=
height_orig
*
3
;
bitmap_lf
.
lfWidth
=
0
;
hfont
=
CreateFontIndirectA
(
&
bitmap_lf
);
assert
(
hfont
);
ret
=
GetObject
(
hfont
,
sizeof
(
lf
),
&
lf
);
ok
(
ret
==
sizeof
(
lf
),
"GetObject failed: %d
\n
"
,
ret
);
ok
(
!
memcmp
(
&
bitmap_lf
,
&
lf
,
FIELD_OFFSET
(
LOGFONTA
,
lfFaceName
)),
"fonts don't match
\n
"
);
ok
(
!
lstrcmpA
(
bitmap_lf
.
lfFaceName
,
lf
.
lfFaceName
),
"font names don't match: %s != %s
\n
"
,
bitmap_lf
.
lfFaceName
,
lf
.
lfFaceName
);
todo_wine
{
test_font_metrics
(
hdc
,
hfont
,
test_str
,
sizeof
(
test_str
),
&
tm_orig
,
&
size_orig
,
width_orig
,
3
,
3
);
}
DeleteObject
(
hfont
);
ReleaseDC
(
0
,
hdc
);
}
START_TEST
(
gdiobj
)
{
test_logfont
();
test_bitmap_font
();
}
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