HFONT CreateFont(nHeight,nWidth,nEscapement,nOrientation,nWeight,cItalic,cUnderline,cStrikeOut,cCharSet,cOutputPrecision,cClipPrecision,cQuality,cPitchAndFamily,lpFacename)
This function creates a logical font that has the specified characteristics. The logical font can subsequently be selected as the font for any device.
Parameter | Type/Description | |
nHeight | int 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. | |
nWidth | int 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 | int Specifies the angle (in tenths of degrees) of each line of text written in the font (relative to the bottom of the page). | |
nOrientation | int Specifies the angle (in tenths of degrees) of each character's baseline (relative to the bottom of the page). | |
nWeight | int Specifies the desired weight of the font in the range 0 to 1000 (for example, 400 is normal, 700 is bold). If nWeight is zero, a default weight is used. | |
cItalic | BYTE Specifies whether the font is italic. | |
cUnderline | BYTE Specifies whether the font is underlined. | |
cStrikeOut | BYTE Specifies whether characters in the font are struck out. | |
cCharSet | BYTE Specifies the desired character set. The following values are predefined: | |
ANSI_CHARSET OEM_CHARSET SYMBOL_CHARSET | ||
The OEM character set is system-dependent. | ||
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. Instead, the strings should be passed directly to the output device driver. | ||
cOutputPrecision | BYTE 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 |
||
cClipPrecision | BYTE 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 | ||
cQuality | BYTE 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 | ||
cPitchAndFamily | BYTE 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 | ||
The four high-order bits 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 |
||
lpFacename | LPSTR Points to a null-terminated character string that specifies the typeface name of the font. The length of this string must not exceed 30 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 does not create a new font. It merely selects the closest match from the fonts available in GDI's pool of physical fonts.