Question

I have read that "Google Web Fonts tries its best to serve the correct versions, but sometimes there are drastic changes between browsers and operating systems."

I would like to use the following in my CSS: font-family: 'Open Sans', sans-serif;

So I included this at the top of my page:

<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Open+Sans:400,700" />

Is this all that I need to do? If that's the case then how can Google Web Fonts decide the correct version for my browser.

Also if I include this then is it likely that the font will exist in my browser. Can I assume that most users will already have a copy of the font?

Was it helpful?

Solution

Google Web Fonts determines the browser with User Agent Sniffing. Here are some examples.

For Google Chrome it returns a WOFF font:

$ curl -A 'Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1667.0 Safari/537.36' http://fonts.googleapis.com/css?family=Open+Sans:400,700
@font-face {
  font-family: 'Open Sans';
  font-style: normal;
  font-weight: 400;
  src: local('Open Sans'), local('OpenSans'), url(http://themes.googleusercontent.com/static/fonts/opensans/v6/cJZKeOuBrn4kERxqtaUH3T8E0i7KZn-EPnyo3HZu7kw.woff) format('woff');
}
@font-face {
  font-family: 'Open Sans';
  font-style: normal;
  font-weight: 700;
  src: local('Open Sans Bold'), local('OpenSans-Bold'), url(http://themes.googleusercontent.com/static/fonts/opensans/v6/k3k702ZOKiLJc3WVjuplzHhCUOGz7vYGh680lGh-uXM.woff) format('woff');
}

For Internet Explorer 10 it returns an EOT and a WOFF font:

$ curl -A 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)' http://fonts.googleapis.com/css?family=Open+Sans:400,700
@font-face {
  font-family: 'Open Sans';
  font-style: normal;
  font-weight: 400;
  src: url(http://themes.googleusercontent.com/static/fonts/opensans/v6/cJZKeOuBrn4kERxqtaUH3fY6323mHUZFJMgTvxaG2iE.eot);
  src: local('Open Sans'), local('OpenSans'), url(http://themes.googleusercontent.com/static/fonts/opensans/v6/cJZKeOuBrn4kERxqtaUH3fY6323mHUZFJMgTvxaG2iE.eot) format('embedded-opentype'), url(http://themes.googleusercontent.com/static/fonts/opensans/v6/cJZKeOuBrn4kERxqtaUH3T8E0i7KZn-EPnyo3HZu7kw.woff) format('woff');
}
@font-face {
  font-family: 'Open Sans';
  font-style: normal;
  font-weight: 700;
  src: url(http://themes.googleusercontent.com/static/fonts/opensans/v6/k3k702ZOKiLJc3WVjuplzHZ2MAKAc2x4R1uOSeegc5U.eot);
  src: local('Open Sans Bold'), local('OpenSans-Bold'), url(http://themes.googleusercontent.com/static/fonts/opensans/v6/k3k702ZOKiLJc3WVjuplzHZ2MAKAc2x4R1uOSeegc5U.eot) format('embedded-opentype'), url(http://themes.googleusercontent.com/static/fonts/opensans/v6/k3k702ZOKiLJc3WVjuplzHhCUOGz7vYGh680lGh-uXM.woff) format('woff');
}

Regarding your second question: Web Fonts are not installed permanently on the client. They only live in the browser cache. If the cache is cleared, the font is downloaded again. Also, if two websites serve the same font from different URLs, the font is loaded twice.

But if the client OS happens to have a certain font installed system-wide, it will use the OS version without downloading. That's what the local sources in the CSS are for.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top