VintaSoft Imaging .NET SDK 14.0: Documentation for .NET developer
Vintasoft.Imaging.Drawing Namespace / DrawingEngine Class / DrawString Methods / DrawString(String,IDrawingFont,IDrawingPen,IDrawingBrush,IGraphicsPath) Method
Syntax Example Requirements SeeAlso
In This Topic
    DrawString(String,IDrawingFont,IDrawingPen,IDrawingBrush,IGraphicsPath) Method (DrawingEngine)
    In This Topic
    Draws the specified Unicode string along the specified path using the specified IDrawingBrush and IDrawingFont objects.
    Syntax
    'Declaration
    
    Public Overloads Sub DrawString( _
    ByVal text
    A string in Unicode encoding to draw.
    As System.String, _
    ByVal font
    The font, which should be used for drawing text.
    As IDrawingFont, _
    ByVal pen
    The pen that determines the color, width, and style of the rectangle.
    As IDrawingPen, _
    ByVal brush
    The brush, which should be used for drawing text.
    As IDrawingBrush, _
    ByVal path
    The path of the drawn text.
    As IGraphicsPath _
    )
    public void DrawString(
    System.String text,
    IDrawingFont font,
    IDrawingPen pen,
    IDrawingBrush brush,
    IGraphicsPath path
    )

    Parameters

    text
    A string in Unicode encoding to draw.
    font
    The font, which should be used for drawing text.
    pen
    The pen that determines the color, width, and style of the rectangle.
    brush
    The brush, which should be used for drawing text.
    path
    The path of the drawn text.
    Example

    Here is an example that shows how to draw string using drawing engine.

    
    ''' <summary>
    ''' Draws a string along graphics path on specified drawing engine.
    ''' </summary>
    ''' <param name="drawingEngine">Drawing engine.</param>
    ''' <param name="area">Area to draw objects in.</param>
    Public Shared Sub DrawStringAlongPathExample(drawingEngine As DrawingEngine, area As RectangleF)
        ' set font size
        Dim fontSize As Single = (area.Width + area.Height) * 0.06F
    
        ' create graphics path, text font and brush
        Using path As IGraphicsPath = drawingEngine.DrawingFactory.CreateGraphicsPath()
            Using font As IDrawingFont = drawingEngine.DrawingFactory.CreateFont("Arial", fontSize, False, False)
                Using brush As IDrawingSolidBrush = drawingEngine.DrawingFactory.CreateSolidBrush(Color.Red)
                    Dim curvePoints As PointF() = New PointF() {New PointF(area.X + area.Width * 0.15F, area.Y + area.Height * 0.5F), New PointF(area.X + area.Width * 0.25F, area.Y + area.Height * 0.2F), New PointF(area.X + area.Width * 0.4F, area.Y + area.Height * 0.2F), New PointF(area.X + area.Width * 0.5F, area.Y + area.Height * 0.5F), New PointF(area.X + area.Width * 0.6F, area.Y + area.Height * 0.8F), New PointF(area.X + area.Width * 0.75F, area.Y + area.Height * 0.8F), _
                        New PointF(area.X + area.Width * 0.85F, area.Y + area.Height * 0.5F)}
                    ' add path elements
                    path.AddCurve(curvePoints)
                    ' draw a string along graphics path
                    drawingEngine.DrawString("Draw string along path example!", font, Nothing, brush, path)
                End Using
            End Using
        End Using
    End Sub
    
    
    
    /// <summary>
    /// Draws a string along graphics path on specified drawing engine.
    /// </summary>
    /// <param name="drawingEngine">Drawing engine.</param>
    /// <param name="area">Area to draw objects in.</param>
    public static void DrawStringAlongPathExample(DrawingEngine drawingEngine, RectangleF area)
    {
        // set font size
        float fontSize = (area.Width + area.Height) * 0.06f;
    
        // create graphics path, text font and brush
        using (IGraphicsPath path = drawingEngine.DrawingFactory.CreateGraphicsPath())
        using (IDrawingFont font = drawingEngine.DrawingFactory.CreateFont("Arial", fontSize, false, false))
        using (IDrawingSolidBrush brush = drawingEngine.DrawingFactory.CreateSolidBrush(Color.Red))
        {
            PointF[] curvePoints = new PointF[]
            {
                new PointF(area.X + area.Width * 0.15f, area.Y + area.Height * 0.5f),
                new PointF(area.X + area.Width * 0.25f, area.Y + area.Height * 0.2f),
                new PointF(area.X + area.Width * 0.40f, area.Y + area.Height * 0.2f),
                new PointF(area.X + area.Width * 0.5f, area.Y + area.Height * 0.5f),
                new PointF(area.X + area.Width * 0.6f, area.Y + area.Height * 0.8f),
                new PointF(area.X + area.Width * 0.75f, area.Y + area.Height * 0.8f),
                new PointF(area.X + area.Width * 0.85f, area.Y + area.Height * 0.5f)
            };
            // add path elements
            path.AddCurve(curvePoints);
            // draw a string along graphics path
            drawingEngine.DrawString("Draw string along path example!", font, null, brush, path);
        }
    }
    
    

    Requirements

    Target Platforms: .NET9; .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

    See Also