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-writing-modes] Support vertical CJK + ttb Arabic (rtl scripts generally) #3608

Open
Zhang-Junzhi opened this issue Feb 2, 2019 · 20 comments
Labels
css-writing-modes-5 i18n-alreq Arabic language enablement i18n-clreq Chinese language enablement i18n-jlreq Japanese language enablement i18n-mlreq Mongolian language enablement i18n-tracker Group bringing to attention of Internationalization, or tracked by i18n but not needing response.

Comments

@Zhang-Junzhi
Copy link
Contributor

In Issue 2754 I proposed a new value horizontal-tb-rl to writing-mode.

Now I would like to bring up an improved proposal to replace the older one:

Instead of adding a new value horizontal-tb-rl to writing-mode, it would be better to add a new property cjk-dir.

Let's think about vertical CJK text together with LTR text. It is reasonably rendered in a consecutiveness way, because vertical CJK characters are "by default" mapped as Top-Left/Bottom-Right in vertical mode:

cjk-dir3

But when it comes to displaying vertical CJK together with RTL text, such as Persian, it is not as readably rendered as with LTR Latin text, because CJK and Persian text are rendered bi-directionally:

cjk-dir1

However, in vertical mode, it shouldn't have had to be in that way, bacause CJK characters can be mapped Top-Right/Bottom-Left as well as Top-Left/Bottom-Right. So here comes the new property cjk-dir, it changes the CJK characters' default directionality(remap them as Top-Right/Bottom-Left), without any necessary rendering change for CJK characters themselves:

cjk-dir2

The image above shows the vertical text with cjk-dir: ltr on the left, and shows the other one with cjk-dir: rtl on the right(being obviously more readable than the left bidi one).

cjk-dir can also as perfectly slove Issue 2754, which was about RTL CJK in horizontal mode.

@Zhang-Junzhi
Copy link
Contributor Author

Zhang-Junzhi commented Feb 2, 2019

I am looking forward to your thoughts. @fantasai @frivoal @kojiishi @r12a @upsuper

@r12a r12a added i18n-tracker Group bringing to attention of Internationalization, or tracked by i18n but not needing response. i18n-jlreq Japanese language enablement i18n-clreq Chinese language enablement i18n-alreq Arabic language enablement i18n-mlreq Mongolian language enablement labels Feb 2, 2019
@frivoal
Copy link
Collaborator

frivoal commented Feb 3, 2019

Leaving aside the question of which property to use to trigger this behavior, I'd like to focus on the use case first.

When we were working on the current version of writing-modes, we used to have text-orientation: sideways-left, which would support this combination of arabic/persian/hebrew/... and chinese/japanese/... where everything goes downwards.

Implementing it was a little more complicated than the rest so browsers were reluctant, but I thought that this made a lot of sense, so I tried to look for evidence that this was needed.

However, after asking around, I could only find people who agreed in theory that this could be nice, but no actual person who actually wanted to do that, or examples of (non-web) documents where this style was used (other than a limited body of Chinese Islamic calligraphic art). To be fair, my research was not particularly deep, but I asked a number of people who should know better than me, and nobody came back with anything useful.

Given the lack of evidence of an actual use case, and the difficulty of implementing it, we dropped text-orientation: sideways-left.

Now, I still think it makes sense in theory to support, so I'd be very interested to hear if you have evidence of an actual need (either people asking for it, or documents using it).

@Zhang-Junzhi
Copy link
Contributor Author

Thank you for your opinion. @frivoal

First, I, for one, am looking forward to applying this in my case. :) That's why I brought up this idea: I am currently learning Persian/Farsi. I also have a specific plan to develop a rich web editor which is adjustable to writing mode. So I want to design a Chinese/Japanese/Korean/Persian/Arabic language-learning website where people can learn from each other, and I want to make the whole website writing-mode-responsive.

Second, one of the main reason of the lack of the reality of combining non-CJK characters in vertical-writing mode is simply the lack of the reality of the vertical-writing mode itself, which is, in my opinion, due to some other remaining issues needed to resolve, for example, you usually need to make greater effort to scroll a horizontal bar than the vertical one in PC. So this makes designers hesitant to design a whole lengthy vertical-writing page. So I don't think the lack of combining non-CJK characters in vertical-writing mode can be independently interpreted as lack of interest, multiple factors interplay.

Third, this property is not only for vertical mode, it's also for RTL CJK characters in horizontal mode(See #2754).

Fourth, I agree with you that this feature makes sense, especially because CSS is an international standard, since this feature is all about better internationalization, isn't it? ;)

Fifth, for vertical mode, this is only about readablity improvement, not an actual functionality, even if UA implementers aren't reluctant in implementing this feature, nothing is going to be hurt at worst.

These are my two cents.

@frivoal
Copy link
Collaborator

frivoal commented Feb 3, 2019

even if UA implementers aren't reluctant in implementing this feature, nothing is going to be hurt at worst.

Writing specifications take time. Writing tests take more time. Discussing these with with lots of potential implementers...

So we generally don't write specifications "just in case".

As far as I can tell, people who actually use vertical CJK mixed with arabic/persian generally use the bidirectional version where the rtl language goes bottom to top. I find it a little surprising, but that's what it is. So CSS as it is today does support international usage.

When I say I looked for evidence that the writing mode where both CJK and rtl languages go down, I didn't just look on the web. I asked a number of professor of arabic studies in Japanese universities, and the like, looking for any document that would be written like that. Maybe I just asked the wrong people, but nobody had seen anything like that before.

Even if it makes sense to me, I'd be reluctant to draft the feature without seeing a single real world document written like that.

I suspect they exist, or at least used to. The current system mostly make sense of you think of non-CJK text as primarily being english, and when you put some arabic into it, you do the usual bidi thing. But China has had many centuries of contact with Persia and the rest of the Arabic speaking world way before english was relevant, and I wouldn't be surprised if documents from back then where written so that everything flows down. But I have yet to see one.

@lianghai
Copy link

lianghai commented Feb 4, 2019

Unclear how this is a CJK-specific issue.

The figures in the original post seem to be about whether RTL scripts take a TTB inline progression in vertical lines. A rather typical use case is how RTL/TTB scripts (such as historical scripts Sogdian and Old Uyghur) can be rendered properly.

This is about how to override the default bidi behavior (as today’s common implementations of vertical writing simply rotate a whole horizontal line without changing the bidi behavior) with a unified direction for inline progression.

@Zhang-Junzhi
Copy link
Contributor Author

Zhang-Junzhi commented Feb 4, 2019

Unclear how this is a CJK-specific issue.

The figures in the original post seem to be about whether RTL scripts take a TTB inline progression in vertical lines. A rather typical use case is how RTL/TTB scripts (such as historical scripts Sogdian and Old Uyghur) can be rendered properly.

This is about how to override the default bidi behavior (as today’s common implementations of vertical writing simply rotate a whole horizontal line without changing the bidi behavior) with a unified direction for inline progression.

Thank you for the reply.

It's really about RTL/LTR, in CSS.

"writing-mode: vertical-*" combined with "direction: ltr" creates TTB inline progression,
while "writing-mode: vertical-*" combined with "direction: rtl" creates BTT inline progression.

It means in vertical mode in CSS, left is "mapped" to top, and right "mapped" to bottom.

"cjk-dir" changes the left to the right mapping in vertical mode.

@Zhang-Junzhi
Copy link
Contributor Author

I wanted to generalize the property to be also useful in horizontal mode.

"cjk-dir: rtl" simply indicates CJK characters are treated like any other RTL characters, such as Arabic, Persian, so they goes the same direction all the way down, regardless in vertical or horizontal mode.

@frivoal
Copy link
Collaborator

frivoal commented Feb 4, 2019

Sorry to insist, but before we discuss the detail of how the property should work or should be called, I think sharing examples of documents (screenshots, pictures, scans...) would be very useful.

As for Sogdian and Old Uyghur, aren't they already supported, as Mongolian and Manchu are, using writing-mode: vertical-lr? (and if not, why not?).

@fantasai
Copy link
Collaborator

fantasai commented Feb 4, 2019

As Florian wrote, we did some fairly extensive research on examples of mixed rtl and ttb scripts. I did find one example of Arabic written downwards, but it was very old: newer examples didn't follow this format. Therefore we didn't design any automatic mechanism for such layouts, instead we added a manual one (text-orientation: sideways-left), which is present in older drafts of Writing Modes. It was later removed because of implementation difficulty and lack of strong use cases. If at some point that balance changes, and a UA is willing to implement sideways-left for mixed-rotation typesetting, then we can issue another level of Writing Modes with the addition. https://www.w3.org/TR/2014/CR-css-writing-modes-3-20140320/#valuedef-sideways-left

But at this point the focus is on getting UAs to support 'writing-mode: sideways-lr', which is much easier, has a wide variety of current use-cases, and last I checked is still only supported in Firefox.

@Zhang-Junzhi
Copy link
Contributor Author

Thanks for reply.

So from your replies, there are one common reason for not adding support for this:

implementation difficulty.

I think the implementation difficulty is primarily due to lack of support of such typography in low-level graphics layer, such as GDK/GTK. I am not sure, but I am interested in looking into this issue in the further.

@upsuper
Copy link
Member

upsuper commented Feb 5, 2019

So from your replies, there are one common reason for not adding support for this: implementation difficulty.

No, it's the combination of lack of usecase (and proof of usecase) and implementation difficulty. If something has strong usecase, and it's not terribly complicated to implement, browsers may still try to do that. writing-mode itself is complicated enough, but it does have strong usecases, which is why it got added and implemented. However, an imaginary usecase is unlikely to be able to justify a complicated implementation.

I think the implementation difficulty is primarily due to lack of support of such typography in low-level graphics layer, such as GDK/GTK. I am not sure, but I am interested in looking into this issue in the further.

I don't think so. I believe the main problem is from calculating various metrics like text position and baseline in layout. There are way too many possible combinations of features can affect text layout. They all need to be taken into consideration when implementing.

Graphics side of this should be identical to what other vertical writing modes require, so it's unlikely to be a problem I suppose.

@Zhang-Junzhi
Copy link
Contributor Author

So from your replies, there are one common reason for not adding support for this: implementation difficulty.

No, it's the combination of lack of usecase (and proof of usecase) and implementation difficulty. If something has strong usecase, and it's not terribly complicated to implement, browsers may still try to do that. writing-mode itself is complicated enough, but it does have strong usecases, which is why it got added and implemented. However, an imaginary usecase is unlikely to be able to justify a complicated implementation.

That's what I meant, it's one of the common reasons.

I think the implementation difficulty is primarily due to lack of support of such typography in low-level graphics layer, such as GDK/GTK. I am not sure, but I am interested in looking into this issue in the further.

I don't think so. I believe the main problem is from calculating various metrics like text position and baseline in layout. There are way too many possible combinations of features can affect text layout. They all need to be taken into consideration when implementing.

Thanks you for the suggestion @upsuper . I meant I am not sure whether typography is native supported by GTK itself, or an uper layer based on GTK. I don't know much about graphics layer programming, would like to look into it, just saying.

@macnmm
Copy link

macnmm commented Feb 5, 2019

In CJ text this can be seen even today but on the right side of vehicles. People are aware that it is read right-to-left. In old signage, as raised above, it is also common in Japan at shrines and temples. This usage is never mixed, so it is not exactly the same as bidi—I do not think mixed script usage is possible here without being too confusing for the contemporary reader. In fact, isn't it true that it was the introduction of Roman text into Japanese newspapers that began the practice of the horizontal headlines to be read LTR, prior to this they were read RTL? It is a cousin of vertical writing, but it is not single-character-per-line vertical; it is horizontal and uses horizontal glyphs, letter spacing, etc.

Therefore I support the introduction of a mode of horizontal writing that is RTL for CJK, perhaps distinct from bidi modes already in use since this is archaic and unlikely to be used outside of very specific edge cases (like reproducing classical signage or in a game where trucks drive past with live text emblazoned on their sides).

@fantasai
Copy link
Collaborator

fantasai commented Feb 6, 2019

@macnmm Writing CJK horizontally can be done with bidi overrides. If we need mixed-script RTL Chinese for reasonably common use cases, then we might need to do something about that, but it'd be a separate issue: this issue seems to be mainly about mixing top-to-bottom RLT text (like Arabic) with vertical Chinese. (I think the summary is a bit misleading, but the OP makes it clear.)

@fantasai fantasai changed the title Proposal: cjk-dir: new property for RTL horizontal CJK, as well as for vertical CJK together with RTL(Arabic, Persian, etc.) text [css-writing-modes] Support vertical CJK + ttb Arabic (rtl scripts generally) Feb 6, 2019
@frivoal
Copy link
Collaborator

frivoal commented Feb 6, 2019

Writing CJK [rtl] horizontally can be done with bidi overrides

Does this fully solve the problem though?

  • Punctuation
    For parentheses and other opening/closing things, it does the right thing.
    For periods, commas and the like, I am unsure what the right thing is.
  • for numeric / alphabetic sub-strings and descendants
    Based on what I understand the expectation to be (as shown in [css-writing-modes] Support rtl Chinese #2754 (comment)), It doesn't solve the problem fully without extra markup, which is unfortunate for a stylistic choice

@dscorbett
Copy link

As for Sogdian and Old Uyghur, aren't they already supported, as Mongolian and Manchu are, using writing-mode: vertical-lr? (and if not, why not?).

@frivoal, it’s because Sogdian and Old Uyghur are RTL in horizontal text and TTB in vertical text, whereas Mongolian is LTR/TTB.

Hieroglyphic Meroitic is another RTL/TTB script, though it’s different in that the glyphs are not rotated in vertical text.

@lianghai
Copy link

@frivoal

As for Sogdian and Old Uyghur, aren't they already supported, as Mongolian and Manchu are, using writing-mode: vertical-lr? (and if not, why not?).

As @dscorbett has pointed out, the commonly implemented vertical layout mechanisms basically rotate a horizontal line 90 degrees (clockwise, typically) to create a vertical line, without rework bidi flows. The result is that RTL scripts have no way to be rendered in the same TTB inline direction in vertical lines as how LTR scripts are.

@garawaa
Copy link

garawaa commented Nov 15, 2019

I think traditional mongolian scripts must be written right to left direction in horizontal position because it originated from arabic scripts.

@Zhang-Junzhi
Copy link
Contributor Author

I think traditional mongolian scripts must be written right to left direction in horizontal position because it originated from arabic scripts.

I think rtl Mongolian in horizontal direction can also be supported like ttb Arabic in vertical direction.

Maybe we need a solution to resolve both the two issues at once.

@lianghai
Copy link

I think traditional mongolian scripts must be written right to left direction in horizontal position because it originated from arabic scripts.

The preferred fallback direction for a script is determined by a user community’s actual preference, not by evolutional or typological analysis.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
css-writing-modes-5 i18n-alreq Arabic language enablement i18n-clreq Chinese language enablement i18n-jlreq Japanese language enablement i18n-mlreq Mongolian 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

9 participants