DrawText(String,IDrawingFont,IDrawingBrush,PointF) Method (DrawingEngine)
Draws the specified text at the specified
System.Drawing.PointF using the specified
IDrawingBrush and
IDrawingFont objects.
Here is an example that shows how to draw text using drawing engine.
''' <summary>
''' Draws text on specified drawing engine.
''' </summary>
''' <param name="drawingEngine">Drawing engine.</param>
''' <param name="area">Area to draw objects in.</param>
Public Shared Sub DrawTextExample(drawingEngine As DrawingEngine, area As RectangleF)
' set font size
Dim fontSize As Single = (area.Width + area.Height) * 0.07F
' create rectangle to locate text
Dim textRect As New RectangleF(area.X, area.Y, area.Width, area.Height)
' create properties for text layout
Dim layoutProperties As New TextLayoutProperties(AnchorType.Center, True)
' create font and brush to draw text
Using font As IDrawingFont = drawingEngine.DrawingFactory.CreateFont("Arial", fontSize, False, True)
Using brush As IDrawingSolidBrush = drawingEngine.DrawingFactory.CreateSolidBrush(Color.Green)
' draw text
drawingEngine.DrawText("Centered text with word wrap example!", font, brush, textRect, layoutProperties)
End Using
End Using
End Sub
/// <summary>
/// Draws text on specified drawing engine.
/// </summary>
/// <param name="drawingEngine">Drawing engine.</param>
/// <param name="area">Area to draw objects in.</param>
public static void DrawTextExample(DrawingEngine drawingEngine, RectangleF area)
{
// set font size
float fontSize = (area.Width + area.Height) * 0.07f;
// create rectangle to locate text
RectangleF textRect = new RectangleF(area.X, area.Y, area.Width, area.Height);
// create properties for text layout
TextLayoutProperties layoutProperties = new TextLayoutProperties(AnchorType.Center, true);
// create font and brush to draw text
using (IDrawingFont font = drawingEngine.DrawingFactory.CreateFont("Arial", fontSize, false, true))
using (IDrawingSolidBrush brush = drawingEngine.DrawingFactory.CreateSolidBrush(Color.Green))
{
// draw text
drawingEngine.DrawText("Centered text with word wrap example!", font, brush, textRect, layoutProperties);
}
}
Target Platforms: .NET9; .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5