Initializes a CFont object with the characteristics given in a LOGFONT structure pointed to by lpLogFont.
Points to a LOGFONT structure that defines the characteristics of the logical font.
The font can subsequently be selected as the current font for any device.
This font has the characteristics specified in the LOGFONT structure. When the font is selected by using the CDC::SelectObject member function, the GDI's font mapper attempts to match the logical font with an existing physical font. If it fails to find an exact match for the logical font, it provides an alternative whose characteristics match as many of the requested characteristics as possible.
When you finish with the CFont object created by the CreateFontIndirect function, first select the font out of the device context, then delete the CFont object.
// 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. // Initializes a CFont object with the characteristics given // in a LOGFONT structure. CFont font; LOGFONT lf; memset(&lf, 0, sizeof(LOGFONT)); // zero out structure lf.lfHeight = 12; // request a 12-pixel-height font strcpy(lf.lfFaceName, "Arial"); // request a face name "Arial" VERIFY(font.CreateFontIndirect(&lf)); // create the font // Do something with the font just created... CClientDC dc(this); 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();