다음을 통해 공유


CFont::CreatePointFontIndirect

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.

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

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.

Return Value

Nonzero if successful, otherwise 0.

Remarks

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;

// clear out structure.
memset(&lf, 0, sizeof(LOGFONT));

// request a 12-pixel-height font
lf.lfHeight = 120;

// request a face name "Arial".
_tcsncpy_s(lf.lfFaceName, LF_FACESIZE, _T("Arial"), 7);  

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, _T("Hello"), 5);
dc.SelectObject(def_font);

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

Requirements

Header: afxwin.h

See Also

Reference

CFont Class

Hierarchy Chart

CFont::CreatePointFont

CFont::CreateFontIndirect