How to render text?

Mar 25, 2010 at 12:47 PM
Edited Mar 25, 2010 at 12:58 PM

I want to render some styled text from SVG to PNG, the svg code works in inkscape or firefox but the output in PNG is a black box. I use the sourcecode from svn.

<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="29" height="18" xmlns="http://www.w3.org/2000/svg" version="1.1"><g font-family="Times New Roman" font-size="18"  title="" >
<text y="18">
<tspan font-style="normal" font-weight="bold" dy="0" fill="Black">
*
</tspan>
<tspan font-style="normal" font-weight="bold" dy="0" fill="Black">
+
</tspan>
</text>
</g>
</svg>

or

<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="29" height="18" xmlns="http://www.w3.org/2000/svg" version="1.1"><g font-family="Times New Roman" font-size="18"  title="" >
<text y="18" fill="black">
<tspan font-style="normal" font-weight="bold" dy="0" ">
*
</tspan>
<tspan font-style="normal" font-weight="bold" dy="0">
+
</tspan>
</text>
</g>
</svg>

I tried the SvgDocument.Open(XmlDocument) and SvgDocument.Open(Stream)

Coordinator
Apr 6, 2010 at 1:29 PM

Hmmm I'm looking into this. As far as I can tell it should work (there is basic support for text) so there must be a bug somewhere. I'll let you know what I find.

 

Apr 7, 2010 at 4:26 PM

Thanks it would help really us if we could use this feature.

It's a very useful lib you create here.

Apr 12, 2010 at 11:19 AM

Ok, here is some new hints. The tspan tag is ignored when i leave it out and use multiple text-tag it's nearly fine. Only thing is, that font-size is not allowed there and i need to superscript a letter then i need it smaller and higher. I could use y to put it up as a workaround but how set it smaller?

My file looks like this right now(in this example there is no need to superscript or multiple text-tags, it would work fine with one):

<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="50" height="18" xmlns="http://www.w3.org/2000/svg" version="1.1">
<g  font-size="18" title="" ><text x="0" y="18" font-family="Times New Roman" font-style="normal" font-weight="normal" fill="black" font-size="18">Y</text>
<text x="19" y="18" font-family="Times New Roman" font-style="normal" font-weight="normal" fill="black" font-size="18">&amp;</text>
<text x="30" y="18" font-family="Times New Roman" font-style="normal" font-weight="normal" fill="black" font-size="18">i</text>
</g>
</svg>