formats: ['woff', 'ttf', 'eot']
Where the files were available relative to the document root at:
WebFontLoader would have to know which types the current User-Agent supports and picks the best one to load by dynamically creating a <style> node appropriately formatted.
Any thoughts? Thanks in advance!
That's an interesting idea. My first thought is that it would require a decent amount of code, thus increasing the side of the library quite a bit.
But, I'd love to see what it looks like - since modules can be added to WebFont Loader at runtime, you don't even need to modify the WebFont Loader code to try it out. Check out the source for a module, like the custom module
New modules are added with:
Well for what it's worth, I've forked and made a preliminary version of how I think this manual module should work:
As far as it requiring a large amount of code, the majority would be with inspecting the userAgent value, which this lib already has code to take care of and I'm in fact utilizing. The changes made in my commit are actually quite minimal to the library itself.
It's probably pretty fragile at the moment, as I've only been doing testing on OSX so far, but I'll do some more testing soon.
I've managed to do some cross-browser testing and got it working on Internet Explorer now, completing the A-Grade browser support. So this module is starting to feel pretty complete, and is probably ready for a pull if you guys are interested (I hope you are!). Thanks in advance!
The beauty of the WebFont#addModule function is that it can be called in an external JS file! Yay! So here's this manual module packaged up as an external module in case you guys would rather not pull to the master / until you do:
That's awesome! I'm very interested in how people would like to work with WFL - do you want the version hosted by Google to grow with every possible module? Or should it have only the minimum? What's the best way to let you build a custom version of WFL with just the modules you need?
(fyi, the code is released as a rubygem which makes some of this a little more possible)
Well I don't know how much flexibility the Google hosting has (i.e. can only serve static files or can also include server-side logic), but I think it would be cool if a specially constructed URL determined which (additional) modules would be included.
would only include 1 or 2 default ones (Google and TypeKit probably). But you could offer additional modules that could be compiled in dynamically through the Google server:
That would rock IMO.
And also FWIW, I DO LIKE the idea of Google hosting pages to help with caching etc. and I DON'T LIKE the idea of hosting my own, modified version. I DON'T MIND the compromise of having Google host the untouched version and having my users download a tiny module for the loader, but in the end I'd LOVE to be able to specify a specially crafted URL that would allow Google to also cache MY code as part of the library that way.
Thanks Nate, I agree that would be ideal.
Jeremie, can you speak to what it would take to get WebFont Loader into the Google api's so we could compile it at runtime?