W3C home > Mailing lists > Public > public-html@w3.org > July 2009

canvas text: ctx.font='inherit'

From: Simon Pieters <simonp@opera.com>
Date: Tue, 21 Jul 2009 08:07:40 +0200
To: "public-html@w3.org" <public-html@w3.org>
Message-ID: <op.uxely2sxidj3kv@zcorpandell.linkoping.osa>
"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

This archive was generated by hypermail 2.3.1 : Thursday, 29 October 2015 10:15:48 UTC