W3C home > Mailing lists > Public > public-canvas-api@w3.org > April to June 2011

Clarification on white space collapsing in measureText()

From: Philip Rogers <pdr@google.com>
Date: Wed, 1 Jun 2011 14:49:59 -0400
Message-ID: <BANLkTimViM3i1wMznSLDDLb0r0pHjWo+PQ@mail.gmail.com>
To: public-canvas-api@w3.org
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

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 19:10:30 UTC