W3C home > Mailing lists > Public > www-svg@w3.org > July 2008

Re: Text alignment with xml:space="preserve"

From: Helder Magalh„es <helder.magalhaes@gmail.com>
Date: Fri, 4 Jul 2008 17:14:09 +0100
Message-ID: <2a1ddf8a0807040914n5bbd83dfkad219716a57cd83b@mail.gmail.com>
To: "Bert Passek" <nucleareffe@gmx.de>
Cc: www-svg@w3.org

> Can anyone here explain me why setting xml:space leads to repositioning of the
> text? Is there another way (maybe by css) to show the correct number of spaces
> with the right text alignment?

The "xml:space" property controls the XML processor's white space
handling [1]. Setting it to "preserve" leads to all whitespace being
kept for processing. That's exactly why your text is being
repositioned - it contains leading (and trailing) white space ! ;-)

To achieve the (apparently) desired effect, one should trim remove all
undesired whitespace:

>        <text style="fill: rgb(0, 0, 0); font-size: 12; font-family:
> &quot;Arial&quot;; baseline-shift: 22%; text-anchor: start;">
>            <tspan x="90.0px" y="120.0px" xml:space="preserve">Dies sind   3 Leerzeichen!</tspan>
>        </text>

This is probably what you want. :-)

Hope this helps,

 Helder Magalh„es

[1] http://www.oracle.com/technology/pub/articles/wang-whitespace.html
Received on Friday, 4 July 2008 16:14:44 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:54:19 UTC