Re: bidi and the initial current text position

Cameron McCormack:
> I’m drafting a message on bidi text, but first I have a question.
> Consider this:
> 
> <style>
>   text { direction: ltr }
>   tspan { direction: rtl; unicode-bidi: bidi-override }
> </style>
> <text x="100"><tspan>AB</tspan> cd</text>
> 
> The visual order of this is “BA cd”.  The <text> has text-anchor:start.
> Where is the text positioned?

Some followup observations.

I’ve always had the expectation that if you have a single value in a
<text> element’s x="" attribute that, at least with text-anchor:start or
text-anchor:end, it will give either the left or right edge of the whole
run of text.  The definition of the text-anchor property certainly gives
that impression:

  start
    The rendered characters are aligned such that the start of the
    resulting rendered text is at the initial current text position. For
    an element with a ‘direction’ property value of "ltr" (typical for
    most European languages), the left side of the text is rendered at
    the initial text position. For an element with a ‘direction’
    property value of "rtl" (typical for Arabic and Hebrew), the right
    side of the text is rendered at the initial text position.

I have another expectation: that that single valued x="" attribute gives
the actual position of the glyph for the first character (in document/
logical order) of the <text> element.  Whether that position is the
left or right edge of the glyph, and how that’s affected by text-anchor,
I am not exactly sure.  This second expectation can’t possibly coexist
with the first, because the first character in document order is the
“A”, and the “A” must be rendered visually in the middle of the text
string (between the “B” and the space).  So 100 can’t be both the
position of the “A” glyph and the left (or right?) edge of the whole run
of text.

Now, this second expectation can’t actually be true, because text-anchor
somehow affects the position of the glyphs.  If you have

  <text x="10" text-anchor="end" direction="ltr">abc</text>

then the position of the “a” glyph isn’t 10 – it’s the position of the
“c” glyph that will be (right aligned) at 10.

So I think the definition of the x="" attribute in the spec,

  If a single <coordinate> is provided, then the value represents the
  new absolute X coordinate for the current text position for rendering
  the glyphs that correspond to the first character within this element
  or any of its descendants.

isn’t right.  text-anchor must somehow influence the position of the
glyph such that the x="" value isn’t the “real” current text position
that is used in the end.

A full version of the example quoted from my first mail is
http://people.mozilla.org/~cmccormack/tests/bidi-position-simple.svg
doesn’t have interop:

  Gecko:        |BA cd  (where “|” is the vertical line at x = 100)
  IE:           |BA cd
  WebKit:  BA cd|
  Opera:   AB cd|
  Batik:        |cd BA

-- 
Cameron McCormack ≝ http://mcc.id.au/

Received on Tuesday, 17 May 2011 22:44:36 UTC