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 across multiple 'tspan' #635

Open
RazrFalcon opened this issue Jan 21, 2019 · 7 comments
Open

BIDI reordering across multiple 'tspan' #635

RazrFalcon opened this issue Jan 21, 2019 · 7 comments

Comments

@RazrFalcon
Copy link

https://www.w3.org/TR/SVG11/text.html#TextLayoutIntroduction

According to the SVG spec, BIDI reordering should be done for a whole text chunk. But it doesn't explain the details.

Reordering of characters due to bidirectionality only occurs within a text chunk.

<svg id="svg1" viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg" font-family="Arial" font-size="32">
    <linearGradient id="lg1">
        <stop offset="0" stop-color="white"/>
        <stop offset="1" stop-color="green"/>
    </linearGradient>

    <rect fill="url(#lg1)" stroke="gray" x="80" y="40" width="93" height="10"/>

    <text id="text1" x="30" y="90">Hel<tspan fill="url(#lg1)">lo مرح</tspan>با.</text>
    <text id="text2" x="30" y="140">Hello مرحبا.</text>

    <rect id="frame" x="1" y="1" width="198" height="198" fill="none" stroke="black"/>
</svg>

test14

As you can see, everything is pretty much broken.

  1. Before writing this test, I thought that librsvg behavior is correct. Meaning that the tspan span doesn't affected by reordering.
  2. Mainly because this leads to the next problem: what is the correct bbox in that case? That's why I'm filling it with a gradient.
    As you can see, Qt thinks that there are two separate objects. librsvg, in my opinion, has the right result (kinda). And the others have a stretched gradient without a white part, for some reasons (rect for the reference).
  3. This is also affected by the tspan and text shaping #634

What is the correct behavior?

@BigBadaboom
Copy link
Contributor

This has been discussed in the past. The latest consensus, if I am remembering correctly, is that paint effects applied to tspans use the bbox of the whole <text> element. So as far as the gradient effect goes, the first four are correct.

The shaping is another matter.

@RazrFalcon
Copy link
Author

RazrFalcon commented Jan 21, 2019

tspans use the bbox of the whole element

Really? I hear it for the first time.

@BigBadaboom
Copy link
Contributor

BigBadaboom commented Jan 21, 2019

SVGTSpanElement doesn't inherit from SVGLocatable. So it has no getBBox() method and thus technically has no bbox of its own.

@RazrFalcon
Copy link
Author

Thanks. I didn't know that.

@AmeliaBR
Copy link
Contributor

Yep. Firefox & Batik are correct here. As Paul noted, the gradient should be stretched to the size of the entire <text> element.

But the glyph selection & position should be the same as if the tspan wasn't there. Because the <tspan> doesn't have any absolute positioning attributes and doesn't change writing mode, it doesn't create a new ”text chunk” for layout and shouldn't affect BiDi.

@Tavmjong
Copy link
Contributor

I agree with Amelia. Inkscape's shaping is wrong. (We are calling pango_shape() rather than pango_shape_full() due to the way our code is structured.)

@css-meeting-bot
Copy link
Member

The SVG Working Group just discussed BIDI reordering across multiple 'tspan', and agreed to the following:

  • RESOLVED: shaping and BIDI occurs across tspan boundaries.
  • RESOLVED: Text shaping should be harmonized with CSS Text
The full IRC log of that discussion <krit> topic: BIDI reordering across multiple 'tspan'
<krit> GitHub: https://github.com//issues/635
<krit> AmeliaBR: I think everyone agreed what should happen. However, some UAs don't do it. Do we need clarifications in the spec? Or just open issues to the UAs?
<krit> Tav: Inkscape is incorrect. Shaping should happen across spans.
<krit> AmeliaBR: markup shouldn't create isolation for reordering. Unless we have the one specific rule of creating layout chunks.
<krit> myles: HTML does shaping across spans
<krit> myles: it is also very common across websites.
<krit> myles: If you don't do shaping between spans it is totally broken. This is a bug we have (in WebKit?).
<krit> myles: we should be consistent between svg and HTML here/
<krit> AmeliaBR: agree with this statement,
<krit> AmeliaBR: Do we need more clear in the spec what is expected?
<krit> AmeliaBR: Right now the BIDI direction is taken on in the general section. Might be worth pulling it out in a dedicated subsection.
<krit> myles: should live close to the BIDI section but no option on editing in general.
<myles> s/option/opinion/
<krit> AmeliaBR: There might be a number of edits required to this chapter. myles, you might be best suited to go through the section since you didn't write it and might not imply things. Would be great if you would be willing to take responsibility for.
<krit> myles: I am willing to help out on it but it might not be valuable to do specific edits but doing general reviews might.
<krit> AmeliaBR: More edits will be required even after todays discussion. The edits need to be made eventually.
<krit> krit: lets start with the review.
<krit> myles: Can not promise but might have time next month.
<krit> myles: we should match what CSS says. It has very detailed text.
<krit> AmeliaBR: in general we should be as consistent as possible.
<krit> proposed RESOLVED: shaping and BIDI occurs across tspan boundaries.
<krit> RESOLVED: shaping and BIDI occurs across tspan boundaries.
<krit> proposed RESOLVED: Text shaping should be harmonised with CSS Text
<krit> RESOLVED: Text shaping should be harmonized with CSS Text

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