Clarification on white space collapsing in measureText()


The HTML5 spec says that the canvas drawText and measureText methods
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 (, white space should
be collapsed. (Philip's canvas tests of measureText require that white space
does collapse).

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

As Darin Adler brought up (,
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?


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