Re: canvas text: web fonts

On Tue, 21 Jul 2009 10:04:23 +0200, Simon Pieters <simonp@opera.com> wrote:

> On Tue, 21 Jul 2009 08:47:58 +0200, Simon Pieters <simonp@opera.com>  
> wrote:
>
>> "Font names must be interpreted in the context of the canvas element's  
>> stylesheets; any fonts embedded using @font-face must therefore be  
>> available. [CSSWEBFONTS]"
>> http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#text
>>
>> What should happen when you fillText() while a font is still loading?
>
> I think blocking is not something we want.
>
> That leaves throwing and using a fallback font.
>
> For an interactive game, it seems more useful to show the fallback font  
> than no text at all, which rules out throwing.
>
> For a static graph, you would either want to draw twice: once with the  
> fallback font, and once again when the font has loaded; or you would  
> want to draw once when the font has loaded.
>
> In order for a Web page to know when a font has loaded, we probably need  
> to introduce an event that is fired when a web font has loaded, or make  
> web font loading delay the load event, or both.

This might be something for the CSS WG to specify, though.

BTW, I think images referenced from CSS should delay the load event, too.
http://software.hixie.ch/utilities/js/live-dom-viewer/saved/176

-- 
Simon Pieters
Opera Software

Received on Tuesday, 21 July 2009 08:19:20 UTC