CFont::CreatePointFontIndirect

BOOL CreatePointFontIndirect( const LOGFONT* lpLogFont, CDC* pDC = NULL );

Return Value

Nonzero if successful, otherwise 0.

Parameters

lpLogFont

Points to a LOGFONT structure that defines the characteristics of the logical font. The lfHeight member of the LOGFONT structure is measured in tenths of a point rather than logical units. (For instance, set lfHeight to 120 to request a 12-point font.)

pDC

Pointer to the CDC object to be used to convert the height in lfHeight to logical units. If NULL, a screen device context is used for the conversion.

Remarks

This function is the same as CreateFontIndirect except that the lfHeight member of the LOGFONT is interpreted in tenths of a point rather than device units. This function automatically converts the height in lfHeight to logical units using the CDC object pointed to by pDC before passing the LOGFONT structure on to Windows.

When you finish with the CFont object created by the CreatePointFontIndirect function, first select the font out of the device context, then delete the CFont object.

Example

// The code fragment shows how to create a font object,
// select the font object into a DC (device context) for text
// drawing, and finally delete the font object.

LOGFONT lf;
memset(&lf, 0, sizeof(LOGFONT));       // clear out structure.
lf.lfHeight = 120;                     // request a 12-pixel-height font
strcpy(lf.lfFaceName, "Arial");        // request a face name "Arial".

CClientDC dc(this);

CFont font;
VERIFY(font.CreatePointFontIndirect(&lf, &dc));   

// Do something with the font just created...
CFont* def_font = dc.SelectObject(&font);
dc.TextOut(5, 5, "Hello", 5);
dc.SelectObject(def_font);

// Done with the font. Delete the font object.
font.DeleteObject();

CFont OverviewClass MembersHierarchy Chart

See Also   CFont::CreatePointFont, CFont::CreateFontIndirect