Re: Clarification on white space collapsing in measureText()

Each of the big browsers are currently failing Philip's measureText() and
drawText() tests that relate to collapsing spaces:
Chrome 12, 13, 14dev
Firefox 4
IE9

I think it makes sense to push on the spec a bit here. Both drawText and
measureText are only called explicitly through javascript and don't support
common layout operations such as newlines or tabs. Since developers already
have to do this type of layout manually (which is appropriate for a
canvas-type surface) I think we should just draw/measure what the user asks
for, without collapsing spaces. This is how each major browser implements
both measureText and drawText at the moment.

Philip

On Tue, Jul 12, 2011 at 11:17 AM, Ian Hickson <ian@hixie.ch> wrote:

> 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 18:31:53 UTC