[whatwg] Still beating the drawString() dead horse...

On Tue, 14 Nov 2006 14:29:44 +0100, Stefan Haustein <sh at kobjects.org>  
wrote:

> Arve Bersvendsen wrote:
>> drawElement() is hardly unpractical, bloated or overkill, since it's  
>> actually probably the only way to get _somewhat_ predictable rendering  
>> of text, pioneered by almost 10 years of CSS. drawString() reintroduces  
>> the unpredictability of font and layout differences without attempting  
>> to solve any of the problem.
>
> Hi Arve,
>
> sometimes it is a good thing not to try to solve all problems at once,  
> in particular in API design.
>
> drawElement() is actually not any little bit more predictable than  
> drawString(). If you disagree, please be specific.

Let's see. CSS and an element interface provides:

1) Specified and predictable white-space handling
2) Specified and predictable font and font-size handling (fallbacks,  
relative and absolute sizes)
3) Specified and predictable line-height handling
4) Inline formatting
5) Color handling

A drawString would have to support all of these to be useful, and by that  
time you'll have reinvented more of CSS than you'd want to.

   var myEle = document.createElement('p');
   myEle.textContent("Hello \nWorld");
   // Or choose any other method of attaching style attributes to elements.
   myEle.style = "color: blue; white-space: pre; font-size: 12px;  
line-height: 2; width: 100px; height: 100px;"
   // ...
   myCanvas2dContext.drawImage(myEle.drawElement(),0,0)

Not too complicated.

-- 
Arve Bersvendsen, Opera Software ASA, http://www.opera.com/

Received on Tuesday, 14 November 2006 05:53:36 UTC