[css3-text] spacing limits are not interoperable

In current implementations, 'letter-spacing' and 'word-spacing'
specifies a fixed additional space applied per-glyph or between words. 
The CSS3 Text turns this property into a set of input parameters used
when justifying text [1]:

  letter-spacing: [ normal | <length> ]{1,3}
  word-spacing:   [ normal | <length> | <percentage> ]{1,3}

where each property can take up to three values specifying the
optimal, minimum and maximum spacing values.  The minimum/maximum
values only have meaning when 'text-align: justify' is used.

However the CSS3 Text spec does not define the justification algorithm
for which these parameters serve as input.  In fact, the spec points
out that depending upon the justification algorithm implemented, the
results can vary widely [2]:

  For instance, a basic but fast ‘inter-word’ justification
  algorithm might use a simple greedy method for determining
  line breaks, then distribute leftover space using the
  spacing limits provided. This algorithm could follow the
  guidelines by expanding word spaces first, expanding
  between letters only if ‘word-spacing’ hit a limit.

  A more sophisticated but slower ‘inter-word’ justification
  algorithm might use a Knuth/Plass method where expansion
  opportunities and limits were assigned weights and
  assessed with other line breaking considerations. This
  algorithm could follow the guidelines by giving more
  weight to word spaces than letter spacing.
  
As I mentioned previously at the San Diego F2F [3], I don't think it
makes sense to define fine-grained parameters like this without also
specifying normatively the justification algorithm with which they are
used.  Authors don't use these parameters as real absolute limits,
they tweak them visually based on the results in a given
implementation for a given text layout.  In an implementation which
implements a "better" justification algorithm (e.g. a paragraph global
algorithm rather than a line local one) this might lead to suboptimal
results which would discourage the use of improved algorithms.

I should also note that more work is needed to specify these controls
precisely.  What happens when both limits are reached?  Text is not
justified or the limits are broken?  Is word spacing always pushed to
it's maximum before letter spacing is adjusted?  Or are the values
pushed towards limits in tandem using some sort of heuristic?

Right now, I think getting a spec out with hyphenation controls
specified is a higher priority.  Whether these fine-grained controls
are necessary or really solve use cases that good hyphenation doesn't
is something that would be better determined once hyphenation is more
widely supported.

John Hudson mentioned this in April [4]:

  The first key to successful full justification is good
  hyphenation, to minimise the variation in word spacing. If
  hyphenation is done properly -- which means analysing more
  than one line of text -- you never get into a situation in
  which letterspacing even occurs as an option.
  
I propose we defer the optimal/min/max spacing limits to a later
version of the Text spec.

Regards,

John Daggett

[1] http://dev.w3.org/csswg/css3-text/#spacing
[2] http://dev.w3.org/csswg/css3-text/#text-justify
[3] http://lists.w3.org/Archives/Public/www-style/2012Aug/0897.html
[4] http://lists.w3.org/Archives/Public/www-style/2012Apr/0271.html

Received on Tuesday, 4 December 2012 05:41:43 UTC