canvas text: ctx.font='inherit'

"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'.

WebKit seems to use 16px serif.

I suggest the spec be changed to support 'inherit' like in Firefox. (The  
spec already looks at the canvas element for 'em' units.)

-- 
Simon Pieters
Opera Software

Received on Tuesday, 21 July 2009 06:08:24 UTC