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

[css-ruby][css-text-decor] Underline position for Japanese text with ruby #1918

Open
upsuper opened this issue Oct 29, 2017 · 8 comments
Open
Labels
css-ruby-1 Current Work i18n-jlreq Japanese language enablement i18n-tracker Group bringing to attention of Internationalization, or tracked by i18n but not needing response.

Comments

@upsuper
Copy link
Member

upsuper commented Oct 29, 2017

(The original topic from my first email in this thread is probably not relevant, as Japanese people have confirmed that the current behavior of Firefox makes sense, and there is probably no clarification needs to be added to the spec. But there is another related issue raised in the thread.)

Copy from my old email:

Masayuki-san mentioned another issue in Twitter: https://twitter.com/d_toybox/status/615061112019513344

This does seem to be an issue.

In our current spec, the positions of underline and ruby annotation are:

  • if underline position is right, the underline is put to the right of the text content [1]
  • the margin box of rbc and rtc are put without intervening space [2]

This means, if both underline and ruby annotation are specified, and author doesn't add any space to either the base or the annotation, the underline and annotation may overlap each other in some fonts.

I have no idea how this issue could be solved. If we want to change the position of underline, the only option is to move it inwards, which may make it overlap with the base text. Hence we cannot do that.

Changing position of ruby annotation isn't quite a good option either, since it could break interop. But given the interop has already been broken due to the height of inline box being UA-defined [3], we probably can do something there?

[1] http://dev.w3.org/csswg/css-text-decor-3/#underline-right
[2] http://dev.w3.org/csswg/css-ruby/#ruby-layout
[3] https://lists.w3.org/Archives/Public/www-style/2015May/0276.html

@upsuper upsuper added css-ruby-1 Current Work css-text-decor-3 Current Work labels Oct 29, 2017
@upsuper
Copy link
Member Author

upsuper commented Oct 29, 2017

Reply from @kojiishi:

I'm leaning not to define the positioning too much in details in this level, so UA-dependent looks good to me.

@upsuper
Copy link
Member Author

upsuper commented Oct 29, 2017

Reply from @fantasai:

Well, text-decoration is defined not to affect layout, so we can't add space.

@upsuper
Copy link
Member Author

upsuper commented Oct 29, 2017

Reply from @kojiishi:

Right, but UA could preserve spaces always, or offset in paint time and overflow if that's more appropriate. I mean, I'm not suggesting that's good, but there are several options when Xidorn said "can do something".

Note that Masayuki is right if he's looking at digital books today. Because "text-underline-position" is not implemented widely yet, and because it defaults to "left" (Chinese), and because of how Blink/WebKit renders CJK underlines today, most EPUB authors I know choose "border-right" instead. Common Japanese vertical CSS includes, for instance:

a {
  text-decoration:none;
  border-right:thin solid;
}

This should result in what Masayuki illustrated when the text contains ruby.

I interpret this as an indication of rendering that way is less bad than other issues.

@upsuper
Copy link
Member Author

upsuper commented Oct 29, 2017

Reply from @fantasai:

No, that's weird. Moving the text on :hover, because it now applies an underline where it didn't before, that's not good from a user perspective...

And adding space always means we add space even when no text decoration is used anywhere. If that's acceptable, we could have

  rt { line-height: normal; }

have special behavior in ruby text, perhaps--defining it as

   normal = 1em + thickness-of-underline

and then put that in the default UA style sheet for <rt>?

@upsuper
Copy link
Member Author

upsuper commented Oct 29, 2017

Reply from me:

It won't help. Ruby annotations are inline boxes [1], and the height of inline boxs is not affected by line-height.

[1] http://dev.w3.org/csswg/css-ruby-1/#ruby-layout

@upsuper
Copy link
Member Author

upsuper commented Oct 29, 2017

Reply from @fantasai:

The height of the visible box isn't affected by line height, but the space allocated to it by layout is controlled entirely by line-height. So I'm confused what you mean?

@upsuper
Copy link
Member Author

upsuper commented Oct 29, 2017

The height of the visible box isn't affected by line height, but the space allocated to it by layout is controlled entirely by line-height. So I'm confused what you mean?

So what I mean is, ruby annotation containers are positioned based on margin box of ruby annotations, and given that ruby annotations are inline box, line-height doesn't contribute anything to margin box (at least in Gecko, I'm not sure which spec may contain description for this).

@fantasai fantasai removed the css-text-decor-3 Current Work label Feb 10, 2018
@r12a r12a added i18n-tracker Group bringing to attention of Internationalization, or tracked by i18n but not needing response. i18n-jlreq Japanese language enablement labels Apr 30, 2018
@frivoal
Copy link
Collaborator

frivoal commented Feb 2, 2021

The spec currently says:

The positions of ruby annotations may be adjusted to avoid potential conflicts with overline and underline decorations applied to the base text.

That seems odd to me, having layout depend on decorations feels odd. I feel that we should just encourage UAs to take advantage of the fact that text-decoration-offset's default value is auto, and that they can place the underline right between with the bases and annotations, where it is least likely to clash with either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
css-ruby-1 Current Work i18n-jlreq Japanese language enablement i18n-tracker Group bringing to attention of Internationalization, or tracked by i18n but not needing response.
Projects
None yet
Development

No branches or pull requests

4 participants