CMFCFontInfo Class
The CMFCFontInfo
class describes the name and other attributes of a font.
Syntax
class CMFCFontInfo : public CObject
Members
Public Constructors
Name | Description |
---|---|
CMFCFontInfo |
Constructs a CMFCFontInfo object. |
Public Methods
Name | Description |
---|---|
CMFCFontInfo::GetFullName | Retrieves the concatenated names of a font and its character set (script). |
Data Members
Name | Description |
---|---|
CMFCFontInfo::m_nCharSet | A value that specifies the character set (script) associated with the font. |
CMFCFontInfo::m_nPitchAndFamily | A value that specifies the pitch and family of the font. |
CMFCFontInfo::m_nType | A value that specifies the type of the font. |
CMFCFontInfo::m_strName | The name of the font; for example, Arial. |
CMFCFontInfo::m_strScript | The name of a character set (script) associated with the font. |
Remarks
You can attach a CMFCFontInfo
object to an item of the CMFCToolBarFontComboBox Class class. Call the CMFCToolBarFontComboBox::GetFontDesc method to retrieve a pointer to a CMFCFontInfo
object.
Example
The following example demonstrates how to use various members of the CMFCFontInfo
class. The example demonstrates how to get a CMFCFontInfo
object from a CMFCRibbonFontComboBox
, and how to access its local variables. This example is part of the MSOffice 2007 Demo sample.
CMFCRibbonFontComboBox *pFontCombo = DYNAMIC_DOWNCAST(CMFCRibbonFontComboBox, pRibbon->FindByID(ID_FONT_FONT));
if (pFontCombo == NULL)
{
return;
}
CCharFormat cf;
cf.szFaceName[0] = NULL;
cf.dwMask = CFM_FACE | CFM_CHARSET;
const CMFCFontInfo *pDesc = pFontCombo->GetFontDesc();
ASSERT_VALID(pDesc);
ASSERT(pDesc->m_strName.GetLength() < LF_FACESIZE);
#if _MSC_VER >= 1300
lstrcpyn(cf.szFaceName, pDesc->m_strName, LF_FACESIZE);
#else
lstrcpynA(cf.szFaceName, T2A((LPTSTR)(LPCTSTR)pDesc->m_strName), LF_FACESIZE);
#endif
cf.bCharSet = pDesc->m_nCharSet;
cf.bPitchAndFamily = pDesc->m_nPitchAndFamily;
Requirements
Header: afxtoolbarfontcombobox.h
CMFCFontInfo::CMFCFontInfo
Constructs a CMFCFontInfo
object.
CMFCFontInfo(
LPCTSTR lpszName,
LPCTSTR lpszScript,
BYTE nCharSet,
BYTE nPitchAndFamily,
int nType);
CMFCFontInfo(const CMFCFontInfo& src);
Parameters
lpszName
[in] The name of the font. For more information, see the lfFaceName
member of the LOGFONT structure.
lpszScript
[in] The name of the script (character set) of the font.
nCharSet
[in] A value that specifies the character set (script) of the font. For more information, see the lfCharSet
member of the LOGFONT structure.
nPitchAndFamily
[in] A value that specifies the pitch and family of the font. For more information, see the lfPitchAndFamily
member of the LOGFONT structure.
nType
[in] A value that specifies the font type. This parameter can be a bitwise combination (OR) of DEVICE_FONTTYPE, RASTER_FONTTYPE, and TRUETYPE_FONTTYPE.
src
[in] An existing CMFCFontInfo
object whose members are used to construct this CMFCFontInfo
object.
Return Value
Remarks
This documentation uses the terms character set and script interchangeably. A script, which is also known as a writing system, is a collection of characters and rules for writing those characters in one or more languages. The collection of characters includes the alphabet and punctuation used in that script. For example, Latin script is used for English as it is spoken in the United States, and its alphabet includes the characters from A through Z. The lfCharSet
member of the LOGFONT structure specifies a character set. For example, the value ANSI_CHARSET specifies the ANSI character set, which includes the alphabet of the Latin script.
CMFCFontInfo::GetFullName
Retrieves the concatenated names of a font and its character set (script).
CString GetFullName() const;
Return Value
A string that contains the font name and script.
Remarks
Use this method to obtain the full name of the font. For example, if the font name is Arial and the font script is Cyrillic, this method returns "Arial (Cyrillic)".
CMFCFontInfo::m_nCharSet
A value that specifies the character set (script) associated with the font.
const BYTE m_nCharSet;
Remarks
For more information, see the nCharSet parameter of the CMFCFontInfo::CMFCFontInfo constructor.
CMFCFontInfo::m_nPitchAndFamily
A value that specifies the pitch (point size) and family (for example, serif, sans-serif, and monospace) of the font.
const BYTE m_nPitchAndFamily;
Remarks
For more information, see the nPitchAndFamily parameter of the CMFCFontInfo::CMFCFontInfo constructor.
CMFCFontInfo::m_nType
A value that specifies the type of the font.
const int m_nType;
Remarks
For more information, see the nType parameter of the CMFCFontInfo::CMFCFontInfo constructor.
CMFCFontInfo::m_strName
The name of the font: for example, Arial.
const CString m_strName;
Remarks
For more information, see the lpszName parameter of the CMFCFontInfo::CMFCFontInfo constructor.
CMFCFontInfo::m_strScript
The name of a character set (script) associated with the font.
const CString m_strScript;
Remarks
For more information, see the lpszScript parameter of the CMFCFontInfo::CMFCFontInfo constructor.
See also
Hierarchy Chart
Classes
CMFCToolBarFontComboBox Class
CMFCToolBarFontSizeComboBox Class