Re: canvas text: ctx.font='inherit'

On Sat, 01 Aug 2009 03:13:09 +0200, Boris Zbarsky <bzbarsky@mit.edu> wrote:

> Ian Hickson wrote:
>> Firefox uses the canvas element's computed value for 'font' for _any_  
>> invalid value passed to the 'font' attribute.
>
> Sort of.  What Firefox does is to treat the font as having the following  
>   declarations specified:
>
>    font: whatever-you-passed-in;
>    line-height: normal;
>
> and then act as if that rule were applied to a node that is the child of  
> the <canvas> element (unless the canvas element is not in the document  
> tree, in which case the style is treated as inheriting from "font: 10px  
> sans-serif".
>
>> I've clarified that 'initial' and 'inherit' must be ignored. I haven't  
>> changed the spec to match either WebKit or Gecko here.
>
> So basically the behavior should be as Firefox now except:
>
> 1)  Treat inherit and initial as CSS syntax errors.
> 2)  Always use "font: 10px sans serif" as the parent's font, not
>      just when the <canvase> is outside of a DOM tree.
>
> Right?

...except when using a relative unit (em, ex, %) or using a relative  
keyword (smaller, larger, bolder, lighter), in which case you inherit from  
the canvas element.

I think it's weird to sometimes inherit from the canvas element and  
sometimes use 10px sans-serif. If we're going to use 10px sans-serif,  
could we make the relative units relative to 10px sans-serif instead of  
the canvas element?

<canvas dir> (or rather the canvas element's 'direction') affects canvas  
text rendering. Maybe direction should be an attribute on the 2d context  
instead for consistency with .font?

-- 
Simon Pieters
Opera Software

Received on Saturday, 1 August 2009 07:53:07 UTC