W3C home > Mailing lists > Public > www-svg@w3.org > May 2001

RE: textLength and text-anchor question...

From: Jon Ferraiolo <jferraio@Adobe.COM>
Date: Tue, 01 May 2001 20:25:26 -0700
Message-Id: <4.2.2.20010501201906.02439f00@mailsj.corp.adobe.com>
To: "Peter" <peter@strings.net>
Cc: <www-svg@w3.org>



At 05:01 PM 5/1/01 -0700, Peter wrote:
>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" ?

The SVG working group has decided to elaborate a bit on the definition of 
'textLength' since the Nov. 2 specification. Here is an updated 
description, which really doesn't say all that much more than the Nov. 2 spec:

textLength:

The author's computation of the total sum of all of the advance values that 
correspond to character data within this element, including the advance 
value on the glyph (horizontal or vertical), the effect of properties 
'kerning', 'letter-spacing' and 'word-spacing' and adjustments due to 
attributes dx and dy on 'tspan' elements. This value is used to calibrate 
the user agent's own calculations with that of the author.
The purpose of this attribute is to allow the author to achieve exact 
alignment, in visual rendering order after any bidirectional reordering, 
for the first and last rendered glyphs that correspond to this element; 
thus, for the last rendered character (in visual rendering order after any 
bidirectional reordering), any supplemental inter-character spacing beyond 
normal glyph advances are ignored (in most cases) when the user agent 
determines the appropriate amount to expand/compress the text string to fit 
within a length of textLength.
A negative value is an error (see Error processing).
If the attribute is not specified, the effect is as if the author's 
computation exactly matched the value calculated by the user agent; thus, 
no advance adjustments are made.
Animatable: yes.

Note that the exact algorithms for fitting text to a particular textLength 
are implementation dependent. The SVG working group felt that this fits in 
the area of black-magic typography and thus we want to allow 
implementations to have the freedom to apply special algorithms to this 
task. (Simple, straightforward algorithms are also possible, and they 
should produce OK results.)

Jon Ferraiolo
SVG Editor
jferraio@adobe.com

>-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 23:30:21 GMT

This archive was generated by hypermail 2.3.1 : Friday, 8 March 2013 15:54:20 GMT