Share via


Graphics::SetTextRenderingHint 方法 (gdiplusgraphics.h)

Graphics::SetTextRenderingHint方法會設定此Graphics物件的文字轉譯模式。

語法

Status SetTextRenderingHint(
  [in] TextRenderingHint newMode
);

參數

[in] newMode

類型: TextRenderingHint

TextRenderingHint列舉的元素,指定此Graphics物件目前用來轉譯文字的程式。

傳回值

類型: 狀態

如果方法成功,它會傳回 Ok,這是 Status 列舉的元素。

如果方法失敗,它會傳回 Status 列舉的其中一個其他元素。

備註

只有在 Windows XP 和 Windows Server 2003 上才支援TextRenderingHintClearTypeGridFit

您無法搭配 CompositingModeSourceCopy 使用 TextRenderingHintClearTypeGridFit

範例

下列範例會將文字轉譯提示設定為兩個不同的值,並繪製文字來示範每個值。

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)));
}

需求

   
最低支援的用戶端 Windows XP、Windows 2000 Professional [僅限傳統型應用程式]
最低支援的伺服器 Windows 2000 Server [僅限傳統型應用程式]
目標平台 Windows
標頭 gdiplusgraphics.h (包含 Gdiplus.h)
程式庫 Gdiplus.lib
Dll Gdiplus.dll

另請參閱

使用文字的反鋸齒

CompositingMode

圖形

Graphics::GetTextRenderingHint

Graphics::SetCompositingMode

TextRenderingHint