CFont is a class in MFC (Microsoft Foundation Classes) which provides an object-oriented approach to font manipulation in Windows applications. GetLogFont is a member function of the CFont class that returns a LOGFONT structure representing the font attributes of a CFont object.
// retrieve the LOGFONT structure LOGFONT lf; font.GetLogFont(&lf);
// output the font name std::wcout << lf.lfFaceName << std::endl;
In this example, a CFont object is created with specific font attributes. The GetLogFont function is then called with a pointer to a LOGFONT structure as its argument. The font name is then output to the console using the lfFaceName member of the LOGFONT structure.
Example 2: Modifying a CFont object using a LOGFONT structure
// create a LOGFONT structure LOGFONT lf = {0}; lf.lfHeight = 20; lf.lfWeight = FW_BOLD; lstrcpy(lf.lfFaceName, _T("Times New Roman"));
// create a CFont object from the LOGFONT structure CFont font; font.CreateFontIndirect(&lf);
// modify the font using the LOGFONT structure LOGFONT new_lf; font.GetLogFont(&new_lf); new_lf.lfHeight = 30; font.DeleteObject(); font.CreateFontIndirect(&new_lf);
In this example, a LOGFONT structure is created with specific font attributes. A CFont object is then created from the LOGFONT structure using the CreateFontIndirect function. The GetLogFont function is called to retrieve the LOGFONT structure from the CFont object, which is then modified by changing the lfHeight member. The original CFont object is then deleted and a new one is created using the modified LOGFONT structure.
C++ (Cpp) CFont::GetLogFont - 12 examples found. These are the top rated real world C++ (Cpp) examples of CFont::GetLogFont extracted from open source projects. You can rate examples to help us improve the quality of examples.