RenderSvgText.vb
''
'' This code is part of Document Solutions for Imaging demos.
'' Copyright (c) MESCIUS inc. All rights reserved.
''
Imports System
Imports System.IO
Imports System.Drawing
Imports System.Collections.Generic
Imports System.Linq
Imports System.Numerics
Imports GrapeCity.Documents.Drawing
Imports GrapeCity.Documents.Text
Imports GrapeCity.Documents.Imaging
Imports GrapeCity.Documents.Svg
Imports GCTEXT = GrapeCity.Documents.Text
Imports GCDRAW = GrapeCity.Documents.Drawing

'' TBD:
Public Class RenderSvgText
    Public Function GenerateImage(
            ByVal pixelSize As Size,
            ByVal dpi As Single,
            ByVal opaque As Boolean,
            Optional ByVal sampleParams As String() = Nothing) As GcBitmap

        '' Load an SVG with text and tspan:
        Dim svgString As String =
            "<svg width='12cm' height='3cm' viewBox='0 0 1000 300' xmlns='http://www.w3.org/2000/svg' version='1.1'>" &
            "  <g font-family='Verdana' font-size='64' >" &
            "    <text x='160' y='180' fill='blue'>Apples are not <tspan font-weight='bold' fill='orange'>oranges</tspan>.</text>" &
            "  </g>" &
            "</svg>"
        Using svg = GcSvgDocument.FromString(svgString)

            '' Render the SVG image and a border around it:
            Dim bmp = New GcBitmap(pixelSize.Width, pixelSize.Height, opaque, dpi, dpi)
            Using g = bmp.CreateGraphics(Color.White)
                Dim pt = New PointF(dpi, dpi)
                g.DrawSvg(svg, pt)
                Dim sz = svg.GetIntrinsicSize(SvgLengthUnits.Pixels)
                g.DrawRectangle(New RectangleF(pt, sz), Color.MediumPurple)
            End Using

            '' Done:
            Return bmp
        End Using
    End Function
End Class