[svgwg] Text layout algorithm: Incorrect "anchored chunk" handling (#839)

tkent-google has just created a new issue for https://github.com/w3c/svgwg:

== Text layout algorithm: Incorrect "anchored chunk" handling ==
Specification: "3. Resolve character positioning" in https://svgwg.org/svg2-draft/text.html#TextLayoutAlgorithm

If an implementation follows the current algorithm,  following two `<text>`s should show different results because "anchored chunk" flags for all characters are cleared in the second one though they are identical in major browsers.

```svg
  <text x="100 100 100" y="50 95 140"
 style="font-size: 42px; text-anchor: middle">I❤SVG</text>
```
```svg
  <text x="100 100 100" y="50 95 140"
 style="font-size: 42px; text-anchor: middle"><tspan>I❤SVG</tspan></text>
```

### What's wrong

Let's trace the algorithm with the second example.  Assume that result[0] is for 'I', result[1] is for '❤', result[2] is for 'S'.

* Procedure _**resolve character positioning**_ for `<text>` sets the "anchored chunk" flags of result[0], result[1], and result[2] to true.  ( 3.2.1.6.1.1 if i < new_check_count, then set the "anchored chunk" flag of result[index + j] to true. Else set the flag to false.)
* Then we enter **_resolve character positioning_** for `<tspan>`.
* It sets the "anchored chunk" flags of result[0], result[1], and result[2] to **false** because _new_chunk_count_ is 0.

The current algorithm also overwrites "anchored chunk" flag set by '2.3. If the character at index i corresponds to a typographic character at the beginning of a line, then set the "anchored chunk" flag of result[i] to true.' and '3.2.2.2. Set the "anchored chunk" flag of result[index] to true.'

I think an easy fix would be
* Do not set false at 3.2.1.6.1.1
* At 3.2.2.2, set result[i] for all of descendant characters of `<textPath>` to false except for result[index].


Please view or discuss this issue at https://github.com/w3c/svgwg/issues/839 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Monday, 19 April 2021 01:40:44 UTC