Re: [svgwg] Typo in Text Layout Algorithm (section 11.5) (#617)

Actually I think there's a little more to this than I'd hoped in my first point. Take this example:
```
<text x="10" dx="20 20">AB</text>
```
this positions the A at 30 and B at 50 in Inkscape, Webkit and Firefox, so I presume that's the intention. But I don't see how this arises from the spec.

Here is section 4 which deals with "dx,dy", modified as I suggested in my original post
```
Let shift be the cumulative x and y shifts due to ‘x’ and ‘y’ attributes, initialized to (0,0).
For each array element with index i in result:
  If resolve_dx[i] is unspecified, set it to 0. If resolve_dy[i] is unspecified, set it to 0.
  Let shift.x = shift.x + resolve_dx[i] and shift.y = shift.y + resolve_dy[i].
  Let result[i].x = CSS_positions[i].x + shift.x and result[i].y = CSS_positions[i].y + shift.y.
```
and here's section 6, which deals with "x" and "y".
```
Let shift be the current adjustment due to the ‘x’ and ‘y’ attributes, initialized to (0,0).
Set index = 1.
While index < count:
  If resolved_x[index] is set, then let shift.x = resolved_x[index] − result.x[index].
  If resolved_y[index] is set, then let shift.y = resolved_y[index] − result.y[index].
  Let result.x[index] = result.x[index] + shift.x and result.y[index] = result.y[index] + shift.y.
```

First, there is the initial line in section 4: I presume the description of shift (and it is only a description, not an instruction) is incorrect, it's the cumulative x and y shifts due to "dx" and "dy", not "x" and "y".

Second, I try to run this algorithm for the example above. The first and second glyphs are shifted by 20 and 40 from their natural positions, which looks correct. But then in section 6 the "x" value overwrites this adjustment for the first glyph:

`If resolved_x[index] is set, then let shift.x = resolved_x[index] − result.x[index].`
This means shift.x = 10 - 20.
`Let result.x[index] = result.x[index] + shift.x`
This means result.x = 20 + -10 = 10, whereas it should be 30.

To sum up: section 6 will ensure that any x/y values replace any previous modifications to x or y, but this doesn't match any implementation I have tested. So I suspect it is section 6 that is at fault, but I'm not familiar enough with the intention to be able to suggest a solution, sorry.



-- 
GitHub Notification of comment by faceless2
Please view or discuss this issue at https://github.com/w3c/svgwg/issues/617#issuecomment-447380919 using your GitHub account

Received on Friday, 14 December 2018 16:40:56 UTC