HFONT CreateFont(nHeight, nWidth, nEscapement, nOrientation, fnWeight, fdwItalic, fdwUnderline, fdwStrikeOut, fdwCharSet, fdwOutputPrecision, fdwClipPrecision, fdwQuality, fdwPitchAndFamily, lpszFace) | |||
int nHeight; | |||
int nWidth; | |||
int nEscapement; | |||
int nOrientation; | |||
int fnWeight; | |||
DWORD fdwItalic; | |||
DWORD fdwUnderline; | |||
DWORD fdwStrikeOut; | |||
DWORD fdwCharSet; | |||
DWORD fdwOutputPrecision; | |||
DWORD fdwClipPrecision; | |||
DWORD fdwQuality; | |||
DWORD fdwPitchAndFamily; | |||
LPCTSTR lpszFace; |
The CreateFont function creates a logical font that has the specified characteristics. The logical font can subsequently be selected as the font for any device.
nHeight
Specifies the desired height (in logical units) of the font. The font height can be specified in three ways: If nHeight is greater than zero, it is transformed into device units and matched against the cell height of the available fonts. If it is zero, a reasonable default size is used. If it is less than zero, it is transformed into device units and the absolute value is matched against the character height of the available fonts. For all height comparisons, the font mapper looks for the largest font that does not exceed the requested size, and, if there is no such font, looks for the smallest font available. This mapping will occur when the font is actually used for the first time.
nWidth
Specifies the average width (in logical units) of characters in the font. If nWidth is zero, the aspect ratio of the device will be matched against the digitization aspect ratio of the available fonts to find the closest match, determined by the absolute value of the difference.
nEscapement
Specifies the angle (in tenths of degrees) of each line of text written in the font (relative to the bottom of the page).
nOrientation
Specifies the angle (in tenths of degrees) of each character's baseline (relative to the bottom of the page).
fnWeight
Specifies the desired weight of the font in the range 0 to 1000 (for example, 400 is normal, 700 is bold). If fnWeight is zero, a default weight is used.
fdwItalic
TRUE if the desired font is Italic.
fdwUnderline
TRUE if text drawn with this font will be underlined.
fdwStrikeOut
TRUE if text drawn with this font will be struck out.
fdwCharSet
Specifies the desired character set. The following values are predefined:
ANSI_CHARSET OEM_CHARSET SYMBOL_CHARSET UNICODE_CHARSET
Fonts with other character sets may exist in the system. If an application uses a font with an unknown character set, it should not attempt to translate or interpret strings that are to be rendered with that font.
fdwOutputPrecision
Specifies the desired output precision. The output precision defines how closely the output must match the requested font's height, width, character orientation, escapement, and pitch. It can be any one of the following values:
OUT_CHARACTER_PRECIS OUT_DEFAULT_PRECIS OUT_STRING_PRECIS OUT_STROKE_PRECIS
fdwClipPrecision
Specifies the desired clipping precision. The clipping precision defines how to clip characters that are partially outside the clipping region. It can be any one of the following values:
CLIP_CHARACTER_PRECIS CLIP_DEFAULT_PRECIS CLIP_STROKE_PRECIS
fdwQuality
Specifies the desired output quality. The output quality defines how carefully GDI must attempt to match the logical-font attributes to those of an actual physical font. It can be any one of the following values:
DEFAULT_QUALITY DRAFT_QUALITY PROOF_QUALITY
fdwPitchAndFamily
Specifies the pitch and family of the font. The two low-order bits specify the pitch of the font and can be any one of the following values:
DEFAULT_PITCH FIXED_PITCH VARIABLE_PITCH
Bits 4 through 7 of the field specify the font family and can be any one of the following values:
FF_DECORATIVE FF_DONTCARE FF_MODERN FF_ROMAN FF_SCRIPT FF_SWISS
lpszFace
Points to a null-terminated character string that specifies the typeface name of the font. The length of this string must not exceed 32 characters. The EnumFonts function can be used to enumerate the typeface names of all currently available fonts.
The return value identifies a logical font if the function is successful. Otherwise, it is NULL.
The CreateFont function may be used as either a wide-character function (where text arguments must use Unicode) or an ANSI function (where text arguments must use characters from the Windows 3.x character set
DeleteObject, SelectObject