Clarification on white space collapsing in measureText()

Background:

The HTML5 spec says that the canvas drawText and measureText methods
should...
3) Replace all the space characters in text with U+0020 SPACE characters.
4) Form a hypothetical infinitely wide CSS line box containing a single
inline box containing the text text, with all the properties at their
initial values except the 'font' property of the inline box set to font and
the 'direction' property of the inline box set to the directionality of the
canvas element. [CSS]

According to the CSS white space model (
http://www.w3.org/TR/CSS2/text.html#white-space-model), white space should
be collapsed. (Philip's canvas tests of measureText require that white space
does collapse).


Question:
Does measureText collapse white space? That is, does "CSS line box" imply a
box that collapses white space?

As Darin Adler brought up (https://bugs.webkit.org/show_bug.cgi?id=61799),
collapsing white space does not seem like the right behavior. With a
monospace font, measureText("A   B") should equal measureText("A+++B"). If
the spec does specify that white space collapses, are there objections to
explicitly /not/ collapsing spaces?

Philip

Received on Thursday, 2 June 2011 09:33:30 UTC