Skybound Rebar

ControlRenderer.MeasureText Method (String, Font, Size, TextRenderFlags)

Provides the size, in pixels, of the specified text when drawn with the specified font and render flags, using the specified size to create the initial bounding rectangle for the text.

[Visual Basic]
Overloads Public Shared Function MeasureText( _
   ByVal text As String, _
   ByVal font As Font, _
   ByVal proposedSize As Size, _
   ByVal flags As TextRenderFlags _
) As Size
[C#]
public static Size MeasureText(
   string text,
   Font font,
   Size proposedSize,
   TextRenderFlags flags
);

Parameters

text
The text to measure.
font
The Font to apply to the measured text.
proposedSize
The Size of the initial bounding rectangle.
flags
The TextRenderFlags to apply to the measured text.

Return Value

The Size, in pixels, of the text.

Remarks

You can manipulate how the text is measured using the flags parameter to pass a combination of TextRenderFlags values. The GetTextRenderFlags method provides a convenient means of obtaining the default set of flags to measure text using a ControlRenderer.

If font, graphics or text is a null reference (Nothing in Visual Basic), the return value is Size.Empty.

MeasureText uses the TextRenderFlags.StandardDrawing flag to determine whether to use GDI or Graphics.DrawString to measure the text.

See Also

ControlRenderer Class | Skybound.Rebar.Rendering Namespace | ControlRenderer.MeasureText Overload List