Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text layout algorithm: Incorrect "anchored chunk" handling #839

Open
tkent-google opened this issue Apr 19, 2021 · 0 comments
Open

Text layout algorithm: Incorrect "anchored chunk" handling #839

tkent-google opened this issue Apr 19, 2021 · 0 comments

Comments

@tkent-google
Copy link
Contributor

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.

  <text x="100 100 100" y="50 95 140"
	style="font-size: 42px; text-anchor: middle">I❤SVG</text>
  <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].
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant