Google Fonts are not rendering on Google Chrome

2020-01-23 07:06发布

I'm building a new WordPress theme (don't know if that's relevant) and there's this issue that keeps bugging me.

I've loaded up Roboto Slab from Google Webfonts (included the CSS in <head> section). On every other browser out there, font is rendered OK, except Google Chrome. When I first load up the website in Google Chrome, texts using that custom font are NOT displayed AT ALL (even tho font-stack has Georgia as a fallback - "Roboto Slab", Georgia, serif;). After I hover the styled link, or retrigger any CSS property in Inspector - texts become visible.

Since I've started the theme some time ago, I can clearly remember that it was working perfectly before. Is this some known recent Chrome update bug?

First load: a screenshot #1

After I reapply any of the CSS properties, get into responsive view or hover an element: a screenshot #2

Anyone have similar issues? How should I proceed with this?

Thanks!

17条回答
▲ chillily
2楼-- · 2020-01-23 07:42

I got it fixed with the JS solution, but also needed to use the latest google hosted jquery (1.11) to get it fixed.

查看更多
\"骚年 ilove
3楼-- · 2020-01-23 07:42

Checkout plugin I made: https://chrome.google.com/webstore/detail/fontfix/ekgfbmjaehhpbakdbpfmlepngjkaalok

It does the web realign with pure javascript, which force browser to redraw whole page.

查看更多
小情绪 Triste *
4楼-- · 2020-01-23 07:43

If anyone is still struggling with this issue (2019), there seems to be a bug in Google Fonts CSS generator script.

I loaded my fonts with the following tag:

<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:400,300">

Every @font-face in the file contained a line like this:

src: local('Roboto'), local('Roboto-Regular'), local('sans-serif'), url(https://fonts.gstatic.com/s/roboto/v19/KFOmCnqEu92Fr1Mu4mxKKTU1Kg.woff2) format('woff2');

As you can see, the local('sans-serif') is placed prior to the remote URL, which is wrong. This causes Chrome to load the default sans-serif font instead of the requested one.

A simple fix is to reorder the font-weight part of the URL, from Roboto:400,300 to Roboto:300,400. This causes the generator to not include the local('sans-serif') source.

Hope it helps someone.

查看更多
做个烂人
5楼-- · 2020-01-23 07:48

If the css fix does not work for you

In case the first rated post is not working, here is a solution:

remove the 'http:' in:

<link href='http://fonts.googleapis.com/css?family=Alfa+Slab+One' rel='stylesheet' type='text/css'> 

or

@import url(http://fonts.googleapis.com/css?family=Alfa+Slab+One);

As explained by David Bain, most modern browsers don't actually require that you specify the protocol, they will "deduce" the protocol based on the context from which you called it

查看更多
可以哭但决不认输i
6楼-- · 2020-01-23 07:48

It's possible that the element has text-rendering: optimizeLegibility set which can cause this, or similar, issues. Changing it to auto fixed this problem for me with a Foundation 5 project that sets it to optimizeLegibility by default.

查看更多
登录 后发表回答