[whatwg] drawString?

Martin Atkins mart at degeneration.co.uk
Tue Jun 6 10:56:45 PDT 2006


Lars Schöning wrote:
> May I suggest the addition of a
> drawString method with parameters for font type, size and string.
> In order to achieve usability canvas really requires an equivalent 
> prototype
> method, however the established prototype functions take immense amounts of
> clocktime and significantly (and unnessessarily) slow down the canvas. The
> current lack of standard in canvas makes it possible to include a 
> drawString
> method before it is too late, thus adding new possibilities to the object.
> 
> 

You can't really implement drawString as a single call, since there's no 
guarantee that the font you requested will be available so you need to 
be ready to deal with that eventuality.

A process which might work is:

* Make a request to prepare some text with an ordered list of preferred 
fonts, CSS-style.
* Get back some kind of descriptor which allows you to discover various 
characteristics of the dimensions of the text as it will be rendered.
* At some later point, ask the canvas to "draw" the descriptor at a 
given location.

This allows for the browser to substitute other fonts while allowing the 
canvas-based app to adapt the display to the characteristics of the 
selected font.




More information about the whatwg mailing list