Hacker News new | ask | show | jobs
by vbezhenar 2026 days ago
> Any correctly-coded website will try a local source first, which should help a lot for poor connections.

Then Google Fonts is not correctly coded, as it'll use remote font only. And myriads of websites reusing Google Fonts snippets. To try local source first, you have to explicitly ask for it in @font-face/src which Google Fonts does not do.

So installing font into your OS won't help you with any website using Google Fonts service.

3 comments

> Then Google Fonts is not correctly coded, as it'll use remote font only.

For a good technical reason: the version installed on the computer may not really match whatever the version on Google Fonts serves (fonts have notoriously no semantic versioning aside from some programmer-oriented fonts, examples of these outside are Segoe UI (changed between Windows 7 and 8) and Liberation fonts (some versions notoriously lack some glyph symbols) and on Google Fonts platform the Exo and Exo 2 problem (which was resolved by renaming the second version to Exo 2)).

Of course, there are also some benefits to Google (you know what are those benefits are).

From the google fonts FAQ it says they will use the locally installed font if possible

https://developers.google.com/fonts/faq#can_i_download_the_f...

> Note that when browsers render websites that use the Google Fonts API, they will check if a font is installed locally on your computer, and prefer to use the local version over web fonts.

Here's snippet from CSS served to my browser:

https://fonts.googleapis.com/css2?family=Inconsolata&display...

    @font-face {
      font-family: 'Inconsolata';
      ...
      src: url(https://fonts.gstatic.com/s/inconsolata/....woff2) format('woff2');
  unicode-range: U+0000-00FF, ...;
Wow! That used to not be the case. I can't find anything about the change but it used to include a check for local(font-face) in the sources.

Some random references to it w/ the snippets:

https://stackoverflow.com/a/52413970

https://stackoverflow.com/questions/18303215/how-can-i-preve...

https://github.com/google/fonts/issues/2620

Thank you, I gave advice and missed this change.

I've created issue "Local font name makes web accessible", and I hope it would be fixed.

https://github.com/google/fonts/issues/2855

I wasn't aware Google Fonts' CSS didn't include local. That's disappointing. Thanks for letting me know!
I've definitely seen use of src:local(...) in the CSS served by Google Fonts in the past, but they may have changed things, or perhaps it depends on details of the request, the detected browser, etc. YMMV.
I just checked on a website I maintain, and it's looks like Google Fonts behaviour has changed. It definitely used to prioritise local fonts, and now it doesn't. In a way, I understand, because local fonts aren't always identical to the online ones, leading to weird bugs that might not be noticed at first (especially in languages that don't use Latin characters). Fonts also get updated over time.

When you select fonts on Google Fonts, the website instructs you to link to CSS hosted by Google, which is simple to implement, but not performant. Really, you would want to load that CSS asynchronously, so that the rendering of the whole website doesn't wait for Google Fonts. (Here's how you load CSS asynchronously, by the way: https://stackoverflow.com/q/32759272/247696 ) Or even better, host the fonts yourself.