Re: [CSS21] Shrink-to-fit width algorithm and hyphen as a line break opportunity

Le 21/09/2012 04:34, "Gérard Talbot" a écrit :
> Q1: Shouldn't an hyphen inside a string normally represent a possible line
> break opportunity?
>
> Q2: Besides a blank space, what else should represent or be considered as
> a normal line break opportunity?
>
> Q3: "CSS 2.1 does not define the exact algorithm." I wonder why. Will CSS
> 3 provide an exact algorithm? This is more about my curiosity than a
> formal question.

Hi,

I am nowhere near an 'authoritative source' on this but line breaking is 
far from obvious, especially with international text. (For example Thai, 
from what I read, does not use spaces but does not allow breaks 
anywhere. Breaking "properly" requires a language dictionary.)

Unicode has the beginning of an answer with the poetically named
UAX #14: http://www.unicode.org/reports/tr14/

But even that can not be universal. Requirements may vary across the 
world, and UAX #14 has a whole section on customization:
http://www.unicode.org/reports/tr14/#Customization

To answer the initial question, UAX #14 puts the U+002D HYPHEN-MINUS 
character in the "HY" breaking class, which is described as "Provide a 
line break opportunity after the character, except in numeric context". 
Some of the actual rules for this are "tailorable": implementation are 
allowed to do something else.


So, unfortunately I’m not sure that CSS can ever have normative 
requirements on line breaking. If you want to test preferred widths and 
shrink-to-fit (without testing the line breaking), I would recommend 
staying in a very small subset of text that everyone agrees how to 
break, maybe only ASCII letters and spaces (no punctuation.) And even 
then, an UA could try to be smart and do automatic hyphenation of words, 
although they may not be allowed to by css3-text without 'hyphens: 
auto'. (The initial value is 'manual'.)

Hope this helps,
-- 
Simon Sapin

Received on Friday, 21 September 2012 08:00:09 UTC