Re: Clarification on white space collapsing in measureText()

On Wed, 1 Jun 2011, Philip Rogers wrote:
> 
> 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?

Per the current spec, your interpretation above seems correct.

Whether the current spec is correct is a different question. :-)


> 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?

What do browsers do today? If the majority of browsers already collapse 
spaces, then it's probably best for interoperability if we continue 
collapsing spaces. If they don't, I'm happy to change the spec.

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

Received on Tuesday, 12 July 2011 15:18:08 UTC