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

SVG Text Layout Algorithm and multiple textPaths #274

Open
karip opened this issue Sep 15, 2016 · 3 comments
Open

SVG Text Layout Algorithm and multiple textPaths #274

karip opened this issue Sep 15, 2016 · 3 comments

Comments

@karip
Copy link

karip commented Sep 15, 2016

The SVG Text Layout Algorithm doesn’t work correctly if <text> has multiple <textPath> elements. Here’s an example: https://jsfiddle.net/x8eug31n/

    <text>
        <textPath href="#P1">ABC</textPath>
        <textPath href="#P2">DEF</textPath>
    </text>

Browsers display this correctly, ‘ABC’ and ‘DEF’ are at the start of their respective paths. The issue is that the SVG Text Algorithm calculates the positions on path wrong. Here’s why:

  1. CSS layout is applied: Lets assume that the result is that ‘ABC’ starts at x coordinate 0, ‘DEF’ starts at x coordinate 40.
  2. The text algorithm (step 8, position on path) uses x coordinate 0 to position ‘ABC’ on path P1, which is approximately at path length 0, which is correct.
  3. The text algorithm uses x coordinate 40 to position ‘DEF’ on path P2, which is approximately at path length 40, which is incorrect. The text should start approximately at path length 0.

I'm using the term 'approximately' here, because the glyph advance also affects the text position on path. But that isn't relevant to this issue.

The algorithm should be modified to work correctly with multiple textPaths to reflect the current browser behaviour, or have a note saying that this is a breaking change.

@Tavmjong
Copy link
Contributor

I agree, the algorithm should be fixed to work according to current browser behavior.

@boggydigital
Copy link
Contributor

Not blocking updated 2.0 CR publication - assigning 2.1 WD milestone

@tkent-google
Copy link
Contributor

tkent-google commented May 13, 2021

I encountered this issue recently.
My workaround is to assume <textPath> has x="0" y="0" by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants