locked
Rendering Text from a SVG file RRS feed

  • Question

  • I have problems rendering text from a SVG file in C# at the correct position. What is the correlation between the x, and y position attributes in the SVG file and the "origin" parameter in the GDI+ method GraphicsPath.AddString(...)? Simply putting in the values from the SVG file shifts the rendered text. I don't see any other simple relationship either, like the origin beeing defined in the bottom left corner and the GDI+ window having it in the top left or something like that.
    Wednesday, June 21, 2006 4:58 PM

Answers

  • Leif,

    We can only help you with the XML aspect of the SVG, not drawing to screen. You may get faster answers if you try Windows Forms related forum.

    Thanks.

    Wednesday, June 21, 2006 8:27 PM

All replies

  • How much is the shift? unlike rect, x y points to the lower left corner of the string.
    Wednesday, June 21, 2006 6:25 PM
  • I just noticed now that it might have something to do with the StringFormat tag in the AddString method. If I use StringFormat.GenericDefault I get the correct x-alignment, but there is still problems in the y-direction. I rendered a circle at the position of the text from the coordinates in the svg-file and it ends up next to the first lower left pixel of the letter as you say. Since the font position in GDI+ is measured from the top left corner I simply take the svg-position and reduce it with the font size. This doesn't work very well apparently - the text is displaced upwards (in the image) maybe 10 pixels or so from the correct position (this might vary with font size (?)).
    Wednesday, June 21, 2006 8:15 PM
  • Sorry, StringFormat.GenericTypographic aligns the text correctly in the x-direction (GenericDefault doesn't)
    Wednesday, June 21, 2006 8:24 PM
  • Leif,

    We can only help you with the XML aspect of the SVG, not drawing to screen. You may get faster answers if you try Windows Forms related forum.

    Thanks.

    Wednesday, June 21, 2006 8:27 PM