[css-text][css-conditional] language specific support for hyphenation and justification

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?

 - Florian

[1] http://practicaltypography.com/justified-text.html
[2] http://www.w3.org/TR/jlreq/
[3] https://en.wikipedia.org/wiki/Kashida

Received on Tuesday, 16 June 2015 12:24:31 UTC