settextstyle

This function is used to set current text style.

void settextstyle(
	int nHeight,
	int nWidth,
	LPCTSTR lpszFace
);
void settextstyle(
	int nHeight,
	int nWidth,
	LPCTSTR lpszFace,
	int nEscapement,
	int nOrientation,
	int nWeight,
	bool bItalic,
	bool bUnderline,
	bool bStrikeOut
);
void settextstyle(
	int nHeight,
	int nWidth,
	LPCTSTR lpszFace,
	int nEscapement,
	int nOrientation,
	int nWeight,
	bool bItalic,
	bool bUnderline,
	bool bStrikeOut,
	BYTE fbCharSet,
	BYTE fbOutPrecision,
	BYTE fbClipPrecision,
	BYTE fbQuality,
	BYTE fbPitchAndFamily
);
void settextstyle(const LOGFONT *font);

Parameters

nHeight

Specify the height (logical units).

nWidth

The average width of the character (logical unit). If 0, the scale is adaptive.

lpszFace

The font name.

nEscapement

The writing angle of the string, in 0.1 degrees.

nOrientation

The writing angle of each character, in 0.1 degrees.

nWeight

The stroke thickness of the character, range 0~1000. 0 indicates the default weight. See the LOGFONT struct for details.

bItalic

Whether italics.

bUnderline

Is there an underscore.

bStrikeOut

Whether there is a strikeout.

fbCharSet

Specifies the character set. See the LOGFONT struct for details.

fbOutPrecision

Specifies the output accuracy of the text. See the LOGFONT struct for details.

fbClipPrecision

Specifies the clip accuracy of the text. See the LOGFONT struct for details.

fbQuality

Specifies the output quality of the text. See the LOGFONT struct for details.

fbPitchAndFamily

Specify the font family that describes the font in a regular way. See the LOGFONT struct for details.

font

A pointer to the LOGFONT structure.

Return Value

None

Examples

// Set the "Consolas" font with a height of 16 pixels as the current font. (VC6 / VC2008 / VC2010 / VC2012)
settextstyle(16, 0, _T("Consolas"));
outtextxy(0, 0, _T("Hello World"));
// Set the output to anti-aliasing  (VC6 / VC2008 / VC2010 / VC2012)
LOGFONT f;
gettextstyle(&f);						// Get the current font settings
f.lfHeight = 48;						// Set the font height to 48
_tcscpy(f.lfFaceName, _T("bold"));		// Set the font to "bold" (high-version VC is recommended to use the function of the _tcscpy_s)
f.lfQuality = ANTIALIASED_QUALITY;		// Set the output to anti-aliasing  
settextstyle(&f);						// Styling fonts
outtextxy(0, 50, _T("Anti-aliasing effect"));
(贡献者:Krissi  编辑