[whatwg] Text APIs on <canvas>

Mathieu HENRI p01 at opera.com
Tue May 6 10:48:21 PDT 2008

Ian Hickson wrote:
> I have introduced the following APIs:
>    context.font
>    context.textAlign
>    context.textBaseline
>    context.fillText()
>    context.strokeText()
>    context.measureText()
> They are defined here:
>    http://www.whatwg.org/specs/web-apps/current-work/#text
> I haven't provided a way to render text to or along a path, nor a way to 
> do vertical text, nor a way to measure anything but the nominal layout 
> width of text (e.g. there's no way to measure bounding boxes or get 
> baseline metrics). I also haven't provided a way to render document 
> fragments straight to a canvas.
> Here is some of the feedback on canvas related to text. I have snipped the 
> feedback that wasn't constructive or didn't provide anything beyond 
> requests for features without use cases and rationale, or that just 
> bickered back and forth without making progress. If I snipped something 
> that you think I should have responded to, please let me know. (I did take 
> everything into account, even the bits that I haven't included below.)
> I haven't made many comments below, because I didn't really have much to 
> say. There were a lot of proposals and requests, but at the end of the day 
> there didn't seem to be strong arguments in favour of some things or other 
> things, so I haven't tried to defend the proposed API I put in the spec 
> relative to the other APIs that were proposed. (I did take the various 
> proposals that were made into account, and tried to adopt the best parts 
> of each one.)
> If you have further feedback, please send comments to the list, as usual.

I can't see any mention that support for Text is optional. Is it 
reasonable with browsers approaching major releases ?

The TextMetrics MUST return have 2 Float readonly properties : the width 
and height. The width alone is not enough.

The methods fillText() and strokeText() could have a 5th optional 
boolean argument called wrapText ( false by default ) to specify if the 
text should wrap or the font-size be decrease in case the text is wider 
than maxWidth.

It is unclear whether the transformations affect the text.

Mathieu 'p01' HENRI
JavaScript developer, Opera Software ASA

More information about the whatwg mailing list