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

On Tue, 21 Jul 2009, Simon Pieters wrote:
>
> "The font DOM attribute, on setting, must be parsed the same way as the 'font'
> property of CSS (but without supporting property-independent stylesheet syntax
> like 'inherit'), ..."
> http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#text
> 
> demo for ctx.font='inherit'
> 
> http://software.hixie.ch/utilities/js/live-dom-viewer/?%3Ccanvas%20style%3D%27font%3A30px%20monospace%27%3Ex%3C%2Fcanvas%3E%0A%3Cscript%3E%0Avar%20c%3Ddocument.querySelector(%27canvas%27).getContext(%272d%27)%3B%0Ac.fillText(%27test%27%2C%200%2C%2020)%3B%0Ac.font%3D%27inherit%27%3B%0Ac.fillText(%27test%27%2C%200%2C%2050)%3B%0A%3C%2Fscript%3E%0A%20%3C%2Fbody%3E%0A%3C%2Fhtml%3E
> 
> Firefox seems to use the canvas element's computed value for 'font'.

Firefox uses the canvas element's computed value for 'font' for _any_ 
invalid value passed to the 'font' attribute.


> WebKit seems to use 16px serif.

WebKit uses the initial value for 'initial' and 'inherit'.


I've clarified that 'initial' and 'inherit' must be ignored. I haven't 
changed the spec to match either WebKit or Gecko here.

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

Received on Friday, 31 July 2009 22:45:25 UTC