Hacker News new | past | comments | ask | show | jobs | submit login

Doesn't Google do some user-agent sniffing for requests for their webfonts to optimize for the target platform?

I guess you would lose these optimizations by hosting them yourself.




Based on your User-Agent, Google's CSS service only responds with a CSS to either a .woff, .woff2 .eot, .svg or .ttf font file. For local hosting you'll need to order these formats in a compatibility sequence, so every browser gets the one it supports (nice writeup here: http://css-tricks.com/snippets/css/using-font-face/).

As all files are the exact same ones Google is hosting in the wild, I don't feel like you'll lose any optimizations (which might be the case when using font generation services like FontSquirrel).


That's not correct. I just downloaded the same google font css using different user agents, one for Windows Google Chrome and one for OS X Google Chrome. CSS were different, both specified .woff2 format but actual font URLs were different. And downloaded .woff2 files were different as well. I used Open Sans font for that test. http://pastebin.com/edYbfxzU here's log, you can try it yourself.


Wow, Thanks you for this paste!

I'll look into that and maybe provide some additional fonts on a per OS/Browser basis to download. The main problem is that it's impossible to have a static CSS snippet AND provide different files per User-Agent (a javascript solution might help). So until I've found a solution to this, you are absolutely right, these optimizations will get lost on local use!

For reference: I'm currently using the following User-Agents for fetching the font file urls from Google's CSS: http://pastebin.com/5SZ1Q6kj


I was going to mention this also. I'm currently working around it with conditional comments (serving /fonts/ie/9+/index.css, etc).

Anyway, thanks for your service, bookmarked... (I've been thinking of doing something similar). Good luck with finding a solution to this problem...


I believe Google strips the font hinting if you're not on Windows, as it's not needed/used by other systems.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: