You can determine the extent of a device's text-writing capabilities by using the GetDeviceCaps function and the TEXTCAPS index. This index directs the function to return a bit flag identifying the text capabilities of the device. For example, you can use the text-capability flag to determine if the given device can use vector fonts, rotate characters, or simulate font attributes such as underlining and italicizing. GDI can simulate vector fonts on a device that does not directly support them by drawing lines.
Most of the text capabilities apply to fonts that are supplied by the device as opposed to those supplied by GDI. Typically, GDI can scale fonts and simulate attributes for the fonts it supplies, but it cannot do so for device-supplied fonts. You can determine how many device fonts there are by using the GetDeviceCaps function with the NUMFONTS index. You can retrieve information about the device fonts by using the EnumFonts function and checking the DEVICE_FONTTYPE bit in the nFontType parameter each time your EnumFonts callback function is called.
The following example shows how to make a list of device-supplied fonts. The GetDeviceCaps function returns the number of device-supplied fonts and EnumFonts creates font handles for each font:
HDC hDC;
HANDLE hDevFonts;
FARPROC lpEnumFunc;
short NumFonts;
.
.
.
int FAR PASCAL EnumFunc(lpLogFont, lpTextMetric, FontType, Data)
LPLOGFONT lpLogFont;
LPTEXTMETRIC lpTextMetric;
short FontType;
LONG Data;
{
PSTR pDevFonts;
short index;
int code = 1;
if (FontType & DEVICE_FONTTYPE) {
pDevFonts = LocalLock(LOWORD(Data));
if (pDevFonts != NULL) {
index = ++pDevFonts[0];
if (index < HIWORD(Data))
pDevFonts[index] = CreateFontIndirect(lpLogFont);
else
code = 0;
}
LocalUnlock(LOWORD(Data));
}
return (code);
}
.
.
.
hDC = GetDC(hWnd);
NumFonts = GetDeviceCaps(hDC, NUMFONTS);
hDevFonts = LocalAlloc(LMEM_FIXED | LMEM_ZEROINIT,
sizeof(HANDLE)*(NumFonts + 1));
lpEnumFunc = MakeProcInstance(EnumFunc, hInst);
EnumFonts(hDC, NULL, lpEnumFunc, MAKELONG(hDevFonts, NumFonts));
FreeProcInstance(lpEnumFunc);