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
3aab64de
Commit
3aab64de
authored
Sep 02, 2004
by
Dmitry Timoshkov
Committed by
Alexandre Julliard
Sep 02, 2004
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a test showing how GDI scales bitmap font metrics.
parent
26e61684
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
134 additions
and
0 deletions
+134
-0
gdiobj.c
dlls/gdi/tests/gdiobj.c
+134
-0
No files found.
dlls/gdi/tests/gdiobj.c
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
();
}
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