RE: textLength and text-anchor question...

Thanks a bunch that helped, even though I dont see a reason why did they
decide
to do it the harder way and define the text chunk only if absolute
coordinates
are given :(what about the combination of dx,y or dy, x?)
Also is there a more detailed definition on "textLength" ?
-peter

-----Original Message-----
From: Jon Ferraiolo [mailto:jferraio@Adobe.COM]
Sent: Monday, April 30, 2001 9:29 AM
To: Peter
Cc: www-svg@w3.org
Subject: Re: textLength and text-anchor question...


Peter,
There are a couple of things going on here. First off, this might seem
non-intuitive, but according to the SVG specification, the 'text-anchor'
property setting on your 'tspan' element has no effect. If you read the
description of 'text-anchor'
(http://www.w3.org/TR/SVG/text.html#TextAnchorProperty), it says:

------------------
The 'text-anchor' property is applied to each individual text chunk within
a given 'text' element. Each text chunk has an initial current text
position, which represents the point in the user coordinate system
resulting from (depending on context) application of the x and y attributes
on the 'text' element, any x or y attribute values on a 'tspan', 'tref' or
'altGlyph' element assigned explicitly to the first rendered character in a
text chunk, or determination of the initial current text position for a
'textPath' element.
------------------

The term 'text chunk' is defined in section 10.7.1
(http://www.w3.org/TR/SVG/text.html#TextChunks). Here is an excerpt:

------------------
Adjustments to the current text position are either absolute position
adjustments or relative position adjustments. An absolute position
adjustment occurs in the following circumstances:

* At the start of a 'text' element
* At the start of each 'textPath' element
* For each character within a 'text', 'tspan', 'tref' and 'altGlyph'
element which has an x or y attribute value assigned to it explicitly

All other position adjustments to the current text position are relative
position adjustments.

Each absolute position adjustment defines a new text chunk. Absolute
position adjustments impact text layout in the following ways:

* Ligatures only occur when a set of characters which might map to a
ligature are all in the same text chunk.
* Each text chunk represents a separate block of text for alignment due to
'text-anchor' property values.
* Reordering of characters due to bidirectionality only occurs within a
text chunk. Reordering does not happen across text chunks.
------------------

Therefore, since the 'tspan' does not set an absolute position, it does not
define a new text chunk, and therefore the 'text-anchor' property does not
have any effect.

The second part has to do with an error in the DTD in the Nov. 2 CR
specification. The 'text-anchor' property was included in entity
PresentationAttributes-TextElements, whereas it should have instead been
included in entity PresentationAttributes-TextContentElements. Because of
this error in the DTD and because Adobe implemented the DTD carefully, even
if you make the 'tspan' into a separate text chunk by assigning an 'x' or
'y' attribute, the Adobe SVG Viewer version 2.0 will not support a
'text-anchor' **attribute** on a 'tspan' element. It will, however, support
the 'text-anchor' property within a 'style' attribute (e.g.,
style='text-anchor:start'). We will fix the DTD and future versions of the
Adobe SVG Viewer are likely to include the corresponding code fix.

Jon Ferraiolo
SVG Editor
jferraio@adobe.com

At 04:07 PM 4/29/01 -0700, Peter wrote:
>Hello,
>
>I have 2 questions regarding proper text and tspan implementations.
>Question 1:
>         How is "textLength" supposed to be calculated (w3c specs dont show
>any formula) e.g. are character widths multiplied by font size when added
>together with kerning and other spacing attributes?
>
>Question 2:
>         What is the right implementation of "text-anchor" within "tspan"?
>According to W3C specs:
>"The 'text-anchor' property is applied to each individual text chunk within
>a given 'text' element. Each text chunk has an initial current text
>position, which represents the point in the user coordinate system
resulting
>from (depending on context) application of the x and y attributes on the
>'text' element, any x or y attribute values on a 'tspan', 'tref' or
>'altGlyph' element assigned explicitly to the first rendered character in a
>text chunk, or determination of the initial current text position for a
>'textPath' element."
>
>Thus the svg below should render text "Text2" over "Text1", however
>according to Adobe SVG viewer 2.0 (build 55) which supposedly has all
>text-anchor features implemented, it renders "Text2" right after "Text1"
>(effectively ingoring text-anchor attrib).  Am I missing something?
>
>   <text  x="200" y="50">Text1
>   <tspan text-anchor="end">Text2</tspan></text>
>
>
>Thanks for your help.
>-peter

Received on Tuesday, 1 May 2001 20:02:15 UTC