I need to convert GraphicsPath to SVG. I used the following piece of code:
SvgDocument d = new SvgDocument();
SvgPath p = new SvgPath();
var a = DrawText(tBText.Text);
string b = "M";
foreach (var item in a.PathPoints)
{
b += " " + item.ToSvgString();
}
p.PathData = SvgPathBuilder.Parse(b);
d.Children.Add(p);
pictureBox1.Image = d.Draw();
d.Write("ss.svg");
DrawText function is here:
private GraphicsPath DrawText(string text)
{
Graphics g = pictureBox1.CreateGraphics();
Font font = new Font("Jameel Noori Nastaleeq", 24, FontStyle.Regular);
GraphicsPath gp = new GraphicsPath();
using (StringFormat sf = new StringFormat())
{
sf.Alignment = StringAlignment.Center;
sf.LineAlignment = StringAlignment.Center;
gp.FillMode = FillMode.Winding;
gp.AddString(text, font.FontFamily, (int)font.Style, font.Size, pictureBox1.ClientRectangle, sf);
gp.ClearMarkers();
g.Clear(Color.Transparent);
g.DrawPath(Pens.Red, gp);
}
return gp;
}
The issue is that it is not converting to SVG properly and the rendering looks corrupted. For example, the word "Hello" looks like this:
![enter image description here](https://i.stack.imgur.com/oXxhx.png)
Where am I going wrong?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…