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-text-4] [text-autospace] Spacing across element boundaries for BiDi content #10803

Open
vitorroriz opened this issue Aug 29, 2024 · 2 comments
Labels
Agenda+ i18n Add to agenda for CSS-i18n calls Agenda+ css-text-4 i18n-tracker Group bringing to attention of Internationalization, or tracked by i18n but not needing response.

Comments

@vitorroriz
Copy link

Spec says:

At element boundaries, the amount of extra spacing introduced between characters is determined by and rendered within the innermost element that contains the boundary.

We need to calculate such spacing before line-breaking as the extra spaces between relevant elements affect the available space for composing a line. At this point visual re-ordering hasn't occurred and ordering is considered logical (we process text in the order it is stored).

After layout, for actually displaying text, if content requires visual re-ordering due to BiDi content, what should the engine do regarding the extra spaces?

  1. We could re-compute spacing based on the potential new visual order, but this won't match the spacing computed during layout, generating a mismatch between "layout" and "display".
  2. We can try to re-use the spacing computed in layout, but that is still "wrong" as we might be adding spacing between characters that are no longer adjacent and missing spacing between characters that are now adjacent.
@vitorroriz
Copy link
Author

cc: @kojiishi @fantasai

@fantasai fantasai added i18n-tracker Group bringing to attention of Internationalization, or tracked by i18n but not needing response. Agenda+ i18n Add to agenda for CSS-i18n calls labels Sep 25, 2024
@fantasai
Copy link
Collaborator

fantasai commented Oct 7, 2024

An example of this would be something like

一些中国字<bdi dir=rtl>HEBREW$SYMBOL$</bdi>中国字.

In visual order it would be

一些中国字$SYMBOL$WERBEH中国字.

If we insert the spaces before reordering, we get

一些中国字 $SYMBOL$WERBEH中国字.

instead of

一些中国字$SYMBOL$WERBEH 中国字.

I think visual-order separation is the right answer, but I'm not sure how important it is to get it right: it'll feel a bit weird either way since we're not setting apart the whole phrase, only half of it. (The autospace rules currently let symbols attach to both CJK and non-CJK contexts, but in this example it's clearly associated with the non-CJK context.) Curious if i18n has realistic examples.

I think the main things we need to ensure are:

  • If both sides of a directional run require autospace, we autospace them appropriately.
  • We never double-autospace either side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Agenda+ i18n Add to agenda for CSS-i18n calls Agenda+ css-text-4 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

3 participants