- From: Xidorn Quan <quanxunzhen@gmail.com>
- Date: Tue, 16 Jun 2015 23:40:12 +1000
- To: Florian Rivoal <florian@rivoal.net>
- Cc: www-style list <www-style@w3.org>, www International <www-international@w3.org>
- Message-ID: <CAMdq69-m0kqcbtbV2Aa2qvzLgR0=ciPjG8cvHRy5eAhQsgwh-A@mail.gmail.com>
On Tue, Jun 16, 2015 at 10:24 PM, Florian Rivoal <florian@rivoal.net> wrote: > Many people (here's one example[1]) recommend that justification should > only be used if you can also do hyphenation, as otherwise it looks bad. > > To do that in a browser, you may be tempted to write this: > > p { text-align: left; } > @supports (hyphens: auto) { > p { > hyphens: auto; > text-align: justify; > } > } > > However, it doesn't quite do cut it. > > * Problem 1 > > Support for hyphenation is language dependent. Even if a browser properly > implements the 'hyphens' property, it may not have a dictionary to do it > for the language at hand. > > * Problem 2 > "justification should only be done if you can also do hyphenation" is only > true in some languages. For example, Japanese does not use hyphenation to > do justification (See [2] for how it's done instead), and languages using > the Arabic script can do pretty justification using kashida[3]. > > Problem 1 would be addressed if we added something like > @supports hyphenation-language(fr) {...} > but it seems awfully specific and narrow. > > Problem 2 can be handled by authors using :lang() selectors, so it is less > of an issue. However, for stylesheets meant to be used over an open ended > set of languages, being exhaustive is really tedious, and authors are > unlikely to have the linguistic knowledge to do this properly. > > We could generalize a little bit, and go with something like (to be > bikesheded): > @supports nice-justification(fr) {...} > where the condition evaluates to true if one of the following is true: > - The language should use hyphenation and the browser has the necessary > resources to do it > - The language should use some other approach (kashida, etc) and the > browser knows how to do at least one of the acceptable techniques > - The language is known not to need any language-specific algorithm or > resource to justify well > > This is broader than @supports hyphenation-language(), but not by a whole > lot, and it deciding which languages need what may be quite controversial, > so I am not sure that's a great idea either. > > Any idea on how to solve this well? > It sounds like a valid use case, but I'm concerned about extending the grammar of @supports. What about adding values to hyphens property which allow authors to specify the language the user agent should use for hyphenating, e.g. "p { hyphens: lang(fr); }" or "p { hyphens: lang-fr; }", and then require the user agent to consider a value invalid if the language specified is not supported. In this way, we don't need to extend the grammar of @supports. In addition, we provide more detailed control to authors about the hyphenating, although other than being a condition, those values are almost useless. - Xidorn
Received on Tuesday, 16 June 2015 13:41:20 UTC