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

Bidi reordering and textchunks give odd results when following SVG 2.0 text algorithm #897

Open
therahedwig opened this issue Oct 30, 2022 · 0 comments

Comments

@therahedwig
Copy link

I've been doing some tests, and found that if the following SVG gives different results in different browsers.

<text  fill="#0000ff" stroke="none" direction="rtl" style="font-family: DejaVu Sans;font-size: 10;"><tspan x="250" y="34">aa bb <tspan style="text-decoration: underline;">حادثتا</tspan> السفينتين بسين cc dd </tspan><tspan fill="#000000" text-anchor="middle"  x="250" dy="10">aa bb <tspan style="text-decoration: underline;">حادثتا</tspan> السفينتين بسين cc dd </tspan></text>

Chromium 106:
image

Firefox 105:
image

Now, SVG 2.0 spec right now says that text chunks should always have their own shaping and reordering, however, that means joined scripts might break, discussed in #631, which then suggests it's undefined. However, the SVG 2.0 text layout algorithm also says "For all other text (SVG 1.1 compatible text and SVG 1.1 like multi-line text), layout the text in a CSS content box that is unconstrained in width and height. " Which means that the following happens:

image

The top being the text as it rolls out of the CSS-based renderer, and the bottom being the SVG text layout algorithm adjusting the positions. Which means that spec-wise, technically the behaviour is defined and Firefox is implementing it correctly.

So, there's the following options:

  1. Layout every text chunk as a separate paragraph. Confuses the idea of a text element being a paragraph, though, and that will affect paragraph-based CSS properties like text-indent.
  2. Insert bidi-controls around each text chunk. I know too little of the bidi algorithm what kind of effect this has.
  3. Recalculate the advances of each glyph so they'll sit snug together. In theory this could have odd results caused by shaping, but I don't know enough of the related algorithms to tell you whether this is a serious issue.
  4. Somehow figure out a way to have each text chunk laid out as a wrapping-line.
  5. Do nothing?

I mostly wanted to make sure people would know that this is what happens if you follow the spec precisely. I am glad SVG 2.0 has proper text-wrapping when as the basic positioning of SVG 1.1 leads to a lot of questions.

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