This project has moved and is read-only. For the latest updates, please go here.

letter spacing

Topics: SVG, SVG# and Parsing, Texts and Fonts
Mar 7, 2012 at 2:21 PM
Edited Mar 8, 2012 at 1:40 PM


I'm using this library as a svg render engine. I'm trying to load some svg files with texts and I see that the "letter-spacing" attribute has no effect. Are there any solutions?

I found also another problem: if I load a svg text with border I see the pen definition, and it's ok; if the text is over a path, the pen definition disappear and it's impossible to see the border in the xaml.

Thank you

Mar 11, 2012 at 1:08 PM


I have not seen any problem with the letter-spacing as you can see in the test samples.
For this and the border issue, if you can create a simple test svg file for me, I will investigate
the issue.

Best regards,

Mar 12, 2012 at 8:22 AM
Edited Mar 12, 2012 at 8:23 AM

Hi Paul,

at the end of this message you can find the body of a svg file whit the problems which I exaplain.


I decided to modify directly your code and I saw that element.GetAttribute("letter-spacing"); return an empty value, so I've wrote a new function. After that I add this progress += LetterSpacing / _pathLength; to the progress value to shift the charters.


For the second problem when you write a text on path you use this method dc.DrawText(formText, _formattedOrigins[i]); that paint glyphs, but glyphs doesn't support stroke property so I changed it with  

Geometry textGeometry = formText.BuildGeometry(new Point(0,0));               

dc.DrawGeometry(Foreground, textPen, ExtractTextPathGeometry(textGeometry));

so texts always are drawed by paths, and paths support stroke.


Another problem that I found the last week was the bounds value of the objects: they go from 0 to a positive value, and if I've a shape with negative coordinates, it will crop. Today I'll try to solve this.





<?xml version="1.0" encoding="UTF-8" standalone="no"?><!-- Created with Inkscape ( -->
<svg   xmlns:dc=""   xmlns:cc=""   xmlns:rdf=""   xmlns:svg=""   xmlns=""   xmlns:xlink=""   xmlns:sodipodi=""   xmlns:inkscape=""   id="svg2"   version="1.1"   inkscape:version="0.48.1 "   sodipodi:docname="newtext.svg">  <defs     id="defs4" />  <metadata     id="metadata7">    <rdf:RDF>      <cc:Work         rdf:about="">        <dc:format>image/svg+xml</dc:format>        <dc:type           rdf:resource="" />        <dc:title></dc:title>      </cc:Work>    </rdf:RDF>  </metadata>  <g     inkscape:label="Livello 1"     inkscape:groupmode="layer"     id="layer1">    <text       xml:space="preserve"       style="font-size:32px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:125%;letter-spacing:5px;word-spacing:0px;fill:#0000ff;fill-opacity:1;stroke:#00ffff;stroke-width:1;stroke-opacity:1;font-family:Arial;-inkscape-font-specification:Arial"       id="text2985"       sodipodi:linespacing="125%"><textPath         xlink:href="#path2992"         id="textPath2994">new text</textPath></text>    <path       sodipodi:type="arc"       style="fill:none;fill-opacity:1;stroke:#00ff00;stroke-width:0.12242937000000000;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"       id="path2992"       sodipodi:cx="106.25"       sodipodi:cy="135.04076"       sodipodi:rx="30.178572"       sodipodi:ry="30.892857"       d="m 136.42857,135.04076 a 30.178572,30.892857 0 1 1 -60.357142,0 30.178572,30.892857 0 1 1 60.357142,0 z"        />  </g></svg>

Mar 27, 2012 at 2:04 PM

Hello Luca,

Thanks for the information and the test file (wished you used the code feature of the Codeplex editor to display it formatted).

I will look into the problem, just give me a little more time.
I have started a new job, working with Java in the first project and I needed to update my Java knowledge, all my current books are even too old :(

Best regards,