Help Center

CGpGraphics.SetTextRenderingHintmethod

Sets the text rendering mode of this **Graphics** object.

GraphicsmethodCGpGraphics.incdocumented

Syntax

FUNCTION SetTextRenderingHint (BYVAL newMode AS TextRenderingHint) AS GpStatus

Parameters

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

Return value

If the function succeeds, it returns StatusOk, which is an element of the GpStatus enumeration.

If the function fails, it returns one of the other elements of the GpStatus enumeration.

Description

Sets the text rendering mode of this Graphics object.

Remarks

The quality associated with each process varies according to the circumstances. TextRenderingHintClearTypeGridFit provides the best quality for most LCD monitors and relatively small font sizes. TextRenderingHintAntiAlias provides the best quality for rotated text. Generally, a process that produces higher quality text is slower than a process that produces lower quality text.

Example

' ======================================================================================== ' The following example sets the text rendering hint to two different values and draws text ' to demonstrate each value. ' ======================================================================================== SUB Example_SetTextRenderingHint (BYVAL hdc AS HDC)

' // Create a graphics object from the window device context DIM graphics AS CGpGraphics = hdc ' // Set the scale transform graphics.ScaleTransformForDpi

' Create font and brush DIM font AS CGpFont = CGpFont("Arial", AfxGdipPointsToPixels(16, TRUE), FontStyleRegular) DIM brush AS CGpSolidBrush = ARGB_BLACK

' Create layout rectangle and string format DIM layoutRect AS GpRectF = (0, 0, 0, 0) DIM format AS CGpStringFormat

' Set rendering hint to low quality and draw text graphics.SetTextRenderingHint(TextRenderingHintSingleBitPerPixel) DIM text AS WSTRING * 128 = "Low quality rendering" graphics.DrawString(text, LEN(text), @font, @layoutRect, @format, @brush)

' Set rendering hint to high quality and draw more text graphics.SetTextRenderingHint(TextRenderingHintAntiAlias) layoutRect.y = 50 text = "High quality rendering" graphics.DrawString(text, LEN(text), @font, @layoutRect, @format, @brush)

END SUB ' ========================================================================================

Reference

  • Include file CGpGraphics.inc
  • Defined in AfxNova/CGpGraphics.inc:181
  • Documented in Graphics/GdiPlus Classes/CGpGraphics Classes.md
  • Topic: CGpGraphics Class