int GetTextFace(hdc, cbBuffer, lpszFace) | |||||
HDC hdc; | /* handle of device context | */ | |||
int cbBuffer; | /* size of buffer for face name | */ | |||
LPSTR lpszFace; | /* pointer to buffer for face name | */ |
The GetTextFace function copies the typeface name of the current font into a buffer. The typeface name is copied as a null-terminated string.
hdc
Identifies the device context.
cbBuffer
Specifies the buffer size, in bytes. If the typeface name is longer than the number of bytes specified by this parameter, the name is truncated.
lpszFace
Points to the buffer for the typeface name.
The return value specifies the number of bytes copied to the buffer, not including the terminating null character, if the function is successful. Otherwise, it is zero.
The following example uses the GetTextFace function to retrieve the name of the current typeface, calls the SetTextAlign function so that the current position is updated when the TextOut function is called, and then writes some introductory text and the name of the typeface by calling TextOut:
int nFaceNameLen;
char aFaceName[80];
nFaceNameLen = GetTextFace(hdc, /* returns length of string */
sizeof(aFaceName), /* size of face-name buffer */
(LPSTR) aFaceName); /* address of face-name buffer */
SetTextAlign(hdc,
TA_UPDATECP); /* updates current position */
MoveTo(hdc, 100, 100); /* sets current position */
TextOut(hdc, 0, 0, /* uses current position for text */
"This is the current face name: ", 31);
TextOut(hdc, 0, 0, aFaceName, nFaceNameLen);