[whatwg] Still beating the drawString() dead horse...
p01 at opera.com
Tue Nov 14 02:34:06 PST 2006
Stefan Haustein wrote:
> I have tried to sum up the requirements for
> CanvasRenderingContext2D.drawString() at
> The page contains an API proposal based on the Font/TextStyle object
> approach that meets all those requirements, and also some motivation
> why I have implemented this approach and not one of the alternatives
> discussed here.
I still think by introducing the drawString() method into Canvas we are
opening the same can of worms that was open in SVG.
If we go that way we will need a drawParagraph() method to draw multi
line strings or blocks of text with wrapping and a bounding width. We
also need to be able to stylize the text, i.e. changing the font-weight
/ color / font-style ... of any word.
The list goes on and on ... and HTML and CSS already cover it all.
The HTMLElement.drawElement() method should be no problem to implement
since userAgents already do render HTMLElements.
Having it return an ImageData object will make it insanely simple to
manipulate in Canvas. The text elements/contents can easily be in the
fall back content of the Canvas tag thus keeping it accessible. Getting
And applying gradients and patterns can be done using a fillRect() with
the appropriate globalCompositeOperation.
Everything (almost) is there. Let's not re-invent a square wheel.
Mathieu 'p01' HENRI
More information about the whatwg