Graphics.SetTextRenderingHint method

Applies to: desktop apps only

The Graphics::SetTextRenderingHint method sets the text rendering mode of this Graphics object.

Syntax

Status SetTextRenderingHint(
  [in]  TextRenderingHint newMode
);

Parameters

newMode [in]

Type: TextRenderingHint

Element of the TextRenderingHint enumeration that specifies the process currently used by this Graphics object to render text.

Return value

Type:

Type: Status

If the method succeeds, it returns Ok, which is an element of the Status enumeration.

If the method fails, it returns one of the other elements of the Status enumeration.

Remarks

TextRenderingHintClearTypeGridFit is supported only on Windows XP and Windows Server 2003.

You cannot use TextRenderingHintClearTypeGridFit along with CompositingModeSourceCopy.

Examples

The following example sets the text rendering hint to two different values and draws text to demonstrate each value.


VOID Example_SetTextRenderingHint(HDC hdc)
{
   Graphics graphics(hdc);

   // Set the text rendering hint to TextRenderingHintSingleBitPerPixel. 
   graphics.SetTextRenderingHint(TextRenderingHintSingleBitPerPixel);

   // Draw text.
   graphics.DrawString(
   L"Low quality rendering",
       21,
   &Font(L"Arial", 24),
   PointF(0, 0),
   &SolidBrush(Color(255, 0, 0, 0)));

   // Get the text rendering hint.
   TextRenderingHint hint = graphics.GetTextRenderingHint();

   // Set the text rendering hint to TextRenderingHintAntiAlias. 
   graphics.SetTextRenderingHint(TextRenderingHintAntiAlias);

   // Draw more text to demonstrate the difference.
   graphics.DrawString(
   L"High quality rendering",
       22,
   &Font(L"Arial", 24),
   PointF(0, 50),
   &SolidBrush(Color(255, 0, 0, 0)));
}

Requirements

Minimum supported client

Windows XP, Windows 2000 Professional

Minimum supported server

Windows 2000 Server

Product

GDI+ 1.0

Header

Gdiplusgraphics.h (include Gdiplus.h)

Library

Gdiplus.lib

DLL

Gdiplus.dll

See also

Graphics
CompositingMode
Graphics::GetTextRenderingHint
Graphics::SetCompositingMode
TextRenderingHint
Antialiasing with Text

 

 

Send comments about this topic to Microsoft

Build date: 3/6/2012

Community Additions

ADD
Show: