- From: Glenn Adams <glenn@skynav.com>
- Date: Thu, 24 May 2012 19:05:06 -0600
- To: "Tab Atkins Jr." <jackalmage@gmail.com>
- Cc: www-style list <www-style@w3.org>
- Message-ID: <CACQ=j+fG-P1Qf7_0taMzgBbPmKqkuddUJuRpOz0+NhmPFRsHow@mail.gmail.com>
On Thu, May 24, 2012 at 6:26 PM, Tab Atkins Jr. <jackalmage@gmail.com>wrote: > I couldn't find anything about this from a cursory search of the list. > > Has any thought been given to exposing when fonts in @font-face are > loaded? (Where "loaded" means "one of the sources is either > successfully downloaded and parsed, or is successfully found on the > local system, or all the sources fail".) > > Our Docs team needs to know this information so it can do accurate > measurements of things, which are based on the metrics of the font > being used. If a fallback font is being used because the main one > hasn't loaded yet, we'll do an initial sizing sweep, then watch for > the load using silly indirect means so we can redo all the sizing when > it loads and we swap out the fonts. > > Right now, our technique is to render two spans positioned off-screen, > one with the fallback font and one with the @font-face font, and poll > the sizes on a timer until the second is a different size than the > first. This is, of course, very silly. It's also not reliable - if > the fallback font happens to produce a span the same width as the > loaded font, you'll never notice the load. This may or may not be > okay for the overall sizing (depends on how close the metrics actually > are, and thus how much of a coincidence the same-size thing was), but > it's definitely bad that it means we have a timer running forever (or > until we hit our own timeout). > > Other fairly advanced apps probably have similar needs. Providing a > load event we can listen to instead of polling would be much less > fragile, more reliable, and cheaper for the user. > > Preferably, it would be fired at the @font-face rule in the CSSOM, so > you don't have to go to any particular effort to figure out which font > it was. If you do something more general like firing it at document, > you have to provide all the descriptors so you can distinguish > separate rules. > > Thoughts? > > ~TJ > > +1
Received on Friday, 25 May 2012 01:05:58 UTC