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
0ceb6b6f
Commit
0ceb6b6f
authored
Jul 18, 2005
by
Robert Shearman
Committed by
Alexandre Julliard
Jul 18, 2005
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement and test GdiGetCharDimensions.
parent
cd4e1e51
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
78 additions
and
0 deletions
+78
-0
font.c
dlls/gdi/font.c
+40
-0
gdi32.spec
dlls/gdi/gdi32.spec
+1
-0
gdiobj.c
dlls/gdi/tests/gdiobj.c
+36
-0
wingdi.h
include/wingdi.h
+1
-0
No files found.
dlls/gdi/font.c
View file @
0ceb6b6f
...
...
@@ -2517,3 +2517,43 @@ done:
memset
(
fs
,
0
,
sizeof
(
FONTSIGNATURE
));
return
ret
;
}
/***********************************************************************
* GdiGetCharDimensions (GDI32.@)
*
* Gets the average width of the characters in the English alphabet.
*
* PARAMS
* hdc [I] Handle to the device context to measure on.
* lptm [O] Pointer to memory to store the text metrics into.
* height [O] On exit, the maximum height of characters in the English alphabet.
*
* RETURNS
* The average width of characters in the English alphabet.
*
* NOTES
* This function is used by the dialog manager to get the size of a dialog
* unit. It should also be used by other pieces of code that need to know
* the size of a dialog unit in logical units without having access to the
* window handle of the dialog.
* Windows caches the font metrics from this function, but we don't and
* there doesn't appear to be an immediate advantage to do so.
*
* SEE ALSO
* GetTextExtentPointW, GetTextMetricsW, MapDialogRect.
*/
LONG
WINAPI
GdiGetCharDimensions
(
HDC
hdc
,
LPTEXTMETRICW
lptm
,
LONG
*
height
)
{
SIZE
sz
;
static
const
WCHAR
alphabet
[]
=
{
'a'
,
'b'
,
'c'
,
'd'
,
'e'
,
'f'
,
'g'
,
'h'
,
'i'
,
'j'
,
'k'
,
'l'
,
'm'
,
'n'
,
'o'
,
'p'
,
'q'
,
'r'
,
's'
,
't'
,
'u'
,
'v'
,
'w'
,
'x'
,
'y'
,
'z'
,
'A'
,
'B'
,
'C'
,
'D'
,
'E'
,
'F'
,
'G'
,
'H'
,
'I'
,
'J'
,
'K'
,
'L'
,
'M'
,
'N'
,
'O'
,
'P'
,
'Q'
,
'R'
,
'S'
,
'T'
,
'U'
,
'V'
,
'W'
,
'X'
,
'Y'
,
'Z'
,
0
};
if
(
lptm
&&
!
GetTextMetricsW
(
hdc
,
lptm
))
return
0
;
if
(
!
GetTextExtentPointW
(
hdc
,
alphabet
,
52
,
&
sz
))
return
0
;
if
(
height
)
*
height
=
sz
.
cy
;
return
(
sz
.
cx
/
26
+
1
)
/
2
;
}
dlls/gdi/gdi32.spec
View file @
0ceb6b6f
...
...
@@ -155,6 +155,7 @@
@ stub GdiDllInitialize
@ stdcall GdiFlush()
@ stdcall GdiGetBatchLimit()
@ stdcall GdiGetCharDimensions(ptr ptr ptr)
@ stub GdiGetLocalBitmap
@ stub GdiGetLocalBrush
@ stub GdiGetLocalDC
...
...
dlls/gdi/tests/gdiobj.c
View file @
0ceb6b6f
...
...
@@ -266,9 +266,45 @@ static void test_gdi_objects(void)
ReleaseDC
(
NULL
,
hdc
);
}
static
void
test_GdiGetCharDimensions
(
void
)
{
HDC
hdc
;
TEXTMETRICW
tm
;
LONG
ret
;
SIZE
size
;
LONG
avgwidth
,
height
;
static
const
char
szAlphabet
[]
=
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
;
typedef
LONG
(
WINAPI
*
fnGdiGetCharDimensions
)(
HDC
hdc
,
LPTEXTMETRICW
lptm
,
LONG
*
height
);
fnGdiGetCharDimensions
GdiGetCharDimensions
=
(
fnGdiGetCharDimensions
)
GetProcAddress
(
LoadLibrary
(
"gdi32"
),
"GdiGetCharDimensions"
);
if
(
!
GdiGetCharDimensions
)
return
;
hdc
=
CreateCompatibleDC
(
NULL
);
GetTextExtentPoint
(
hdc
,
szAlphabet
,
strlen
(
szAlphabet
),
&
size
);
avgwidth
=
((
size
.
cx
/
26
)
+
1
)
/
2
;
ret
=
GdiGetCharDimensions
(
hdc
,
&
tm
,
&
height
);
ok
(
ret
==
avgwidth
,
"GdiGetCharDimensions should have returned width of %ld instead of %ld
\n
"
,
avgwidth
,
ret
);
ok
(
height
==
tm
.
tmHeight
,
"GdiGetCharDimensions should have set height to %ld instead of %ld
\n
"
,
tm
.
tmHeight
,
height
);
ret
=
GdiGetCharDimensions
(
hdc
,
&
tm
,
NULL
);
ok
(
ret
==
avgwidth
,
"GdiGetCharDimensions should have returned width of %ld instead of %ld
\n
"
,
avgwidth
,
ret
);
ret
=
GdiGetCharDimensions
(
hdc
,
NULL
,
NULL
);
ok
(
ret
==
avgwidth
,
"GdiGetCharDimensions should have returned width of %ld instead of %ld
\n
"
,
avgwidth
,
ret
);
height
=
0
;
ret
=
GdiGetCharDimensions
(
hdc
,
NULL
,
&
height
);
ok
(
ret
==
avgwidth
,
"GdiGetCharDimensions should have returned width of %ld instead of %ld
\n
"
,
avgwidth
,
ret
);
ok
(
height
==
size
.
cy
,
"GdiGetCharDimensions should have set height to %ld instead of %ld
\n
"
,
size
.
cy
,
height
);
DeleteDC
(
hdc
);
}
START_TEST
(
gdiobj
)
{
test_logfont
();
test_bitmap_font
();
test_gdi_objects
();
test_GdiGetCharDimensions
();
}
include/wingdi.h
View file @
0ceb6b6f
...
...
@@ -3335,6 +3335,7 @@ BOOL WINAPI GdiAlphaBlend(HDC,int,int,int,int,HDC,int,int,int,int,BLENDFUNC
BOOL
WINAPI
GdiComment
(
HDC
,
UINT
,
const
BYTE
*
);
DEVMODEW
*
WINAPI
GdiConvertToDevmodeW
(
const
DEVMODEA
*
);
BOOL
WINAPI
GdiFlush
(
void
);
LONG
WINAPI
GdiGetCharDimensions
(
HDC
,
LPTEXTMETRICW
,
LONG
*
);
BOOL
WINAPI
GdiGradientFill
(
HDC
,
PTRIVERTEX
,
ULONG
,
PVOID
,
ULONG
,
ULONG
);
BOOL
WINAPI
GdiIsMetaFileDC
(
HDC
);
BOOL
WINAPI
GdiIsMetaPrintDC
(
HDC
);
...
...
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