Detailed explanation of the CreateFontW font creation function in VS2019 MFC
The CreateFontW function is a Windows API function used for creating fonts, and can also be used in MFC to create fonts. The detailed explanation of the function is as follows:
Prototype of function:
HFONT CreateFontW(
int height,
int width,
int escapement,
int orientation,
int weight,
DWORD italic,
DWORD underline,
DWORD strikeOut,
DWORD charSet,
DWORD outputPrecision,
DWORD clipPrecision,
DWORD quality,
DWORD pitchAndFamily,
LPCWSTR faceName
);
Interpretation of parameters:
- nHeight: The height of the font characters can be either a positive value for pixel height or a negative value for device unit height.
- nWidth: The character width of the font can be a positive or negative value, with positive values indicating pixel width and negative values indicating device unit width. In most cases, setting it to 0 is sufficient.
- The nEscapement parameter determines the italic angle of the font characters, with a default value of 0 representing no slant.
- Orientation: The angle at which characters of the font are rotated (in increments of 0.1 degrees), with a default of 0 indicating no rotation.
- FW_DONTCARE: Do not care about the thickness of the font.
- FW_THIN: Thin font.
- FW_NORMAL: Regular font.
- FW_BOLD: bold text.
- FW_BLACK: Black font.
- Other customized font thickness options.
- Incorrect: Do not use italics.
- TRUE: Use italics.
- FALSE: There are no underlines.
- TRUE: There are underlines.
- INCORRECT: There is no strikethrough.
- TRUE: has a strikethrough.
- ANSI_CHARSET: ANSI character set.
- DEFAULT_CHARSET: the default character set.
- Symbol character set: a set of symbols.
- Other custom character sets.
- Default precision.
- String precision.
- Character precision.
- Pen stroke precision.
- TrueType precision.
- OUT_DEVICE_PRECIS: Device Precision.
- Raster precision.
- Precision using only TrueType fonts.
- Outline precision.
- CLIP_DEFAULT_PRECIS: Default cropping.
- Clip character precisely.
- Clip stroke trimming.
- CLIP_MASK: Clipping mask.
- CLIP_LH_ANGLES: crop the top left and bottom right corners.
- Always clip TrueType fonts.
- EMBEDDED CLIPPING: An embedded cut.
- The default quality setting.
- Draft quality: the quality of a rough draft.
- PROOF_QUALITY: the quality of proofreading.
- NONANTIALIASED_QUALITY: Quality without anti-aliasing.
- Antialiased quality: high-quality edge smoothing.
- fdwPitchAndFamily: The spacing and family of the font. The spacing can