views:

44

answers:

0

Is there any way to tell when an @font-face rule is applied? I'm creating @font-face rules that use data: URIs from a font file requested with an synchronous XMLHttpRequest in JavaScript and then write text to a canvas element using the font right away. The thing is that it doesn't actually use the font when drawing the text for the first few milliseconds. My current solution is to block execution for a few milliseconds by sending a synchronous XMLHttpRequest, which is a terrible solution.

I cannot make this asynchronous as it is for implementing Processing's loadFont() function, which is synchronous, in Processing.js.

I would prefer that the solution not check the dimensions of character as there's no guarantee that the font has a certain character and that its dimensions are different from the same character of the current font.