Google Fonts are not rendering on Google Chrome

HtmlCssGoogle ChromeGoogle Webfonts

Html Problem Overview


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:

enter image description here

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

enter image description here

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

Thanks!

Html Solutions


Solution 1 - Html

Apparently it's a known Chrome bug. There's a css-only workaround that should solve the problem:

body {
    -webkit-animation-delay: 0.1s;
    -webkit-animation-name: fontfix;
    -webkit-animation-duration: 0.1s;
    -webkit-animation-iteration-count: 1;
    -webkit-animation-timing-function: linear;
}

@-webkit-keyframes fontfix {
    from { opacity: 1; }
    to   { opacity: 1; }
}

It seems like Chrome just needs to be told to repaint the text

Solution 2 - Html

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

Solution 3 - Html

The CSS fix didn't work for me, also the 0.5 sec delay script seems awkward.

This JS snippet seems to work for us:

<script type="text/javascript">
jQuery(function($) {
    if (/chrom(e|ium)/.test(navigator.userAgent.toLowerCase())) {
        $('body').css('opacity', '1.0')	
    }
})
</script>

Solution 4 - Html

Tried the css fix alone above with no success. Finally resolved by creating a style sheet (chrome.css) containing:

body {
 -webkit-animation-delay: 0.1s;
 -webkit-animation-name: fontfix;
 -webkit-animation-duration: 0.1s;
 -webkit-animation-iteration-count: 1;
 -webkit-animation-timing-function: linear;
}

@@-webkit-keyframes fontfix {
 from { opacity: 1; }
 to   { opacity: 1; }
}

And loading it with jquery at the bottom of the page:

<script type="text/javascript">
   $(document).ready(function () {
      $('head').append('<link href="/chrome.css" rel="stylesheet" />');
   });
</script>

Solution 5 - Html

I've incorporated the above CSS ... but I ALSO am including the following javascript in my header:

(Note, I know I haven't customized the fonts in the code below. But regardless, it still seems to help in forcing Chrome to repaint the fonts on the page ... just make sure your fonts are properly referenced elsewhere)

With the CSS mentioned above used in conjunction with the below code included in my ... at worst, all fonts on my page will show up after a second or so of delay.

Hope this helps people. Cheers.

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script type="text/javascript" charset="utf-8">

 $(function() { $('body').hide().show(); });
</script>


<script type="text/javascript">
					
//JavaScript goes here


WebFontConfig = {
  google: { families: ['FontOne', 'FontTwo'] },
    fontinactive: function (fontFamily, fontDescription) {
   //Something went wrong! Let's load our local fonts.
    WebFontConfig = {
      custom: { families: ['FontOne', 'FontTwo'],
      urls: ['font-one.css', 'font-two.css']
    }
  };
  loadFonts();
  }
};

function loadFonts() {
  var wf = document.createElement('script');
  wf.src = ('https:' == document.location.protocol ? 'https' : 'http') +
    '://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
  wf.type = 'text/javascript';
  wf.async = 'true';
  var s = document.getElementsByTagName('script')[0];
  s.parentNode.insertBefore(wf, s);
}

(function () {
  //Once document is ready, load the fonts.
  loadFonts();
  })();

</script>

Here's where I found the above: https://productforums.google.com/forum/#!topic/chrome/tYHSqc-fqso

Solution 6 - Html

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

Solution 7 - Html

I just faced the same issue. I it was due to HTTP/S protocol mismatch as described here.

Use https version of URL.

Solution 8 - Html

See similar problem in question https://stackoverflow.com/questions/27568591/strange-issue-while-google-font-rendering.

Solution is in loading the desired font (I my case 'Fira Sans') from the Mozilla CDN instead of Google CDN.

Solution 9 - Html

It is not a actual solution but it works better for me than everything else in this thread. I changed the font. I had Fira Sans and now just changed to Roboto which works out of the box.

Solution 10 - Html

i just used to delete roboto font from my windows fonts and every thing work right now.

it is maybe beacause you have older version of font on your system . i guess .

Solution 11 - Html

I was trying to work with Meg's answer,but like many others it didn't work for me either.

For using Google Font,found this trick[Adding Screenshots for steps].

  1. Just take the url from the css or standard link as highlighted.

  2. Open the link in another tab, copy whole css code(i.e. font-face) in your css file and run.

Not sure about performance as many http calls are getting added, or just try copying one font-face.

Image for step 1 enter image description here

Image for step 2 enter image description here

Solution 12 - Html

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.

Solution 13 - Html

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.

Solution 14 - Html

I'm just sharing what worked for me. Your results may vary.

I had main.css with an @import of multiple fonts, separated by a | (pipe) character. This had been working up until today. I kept all of my Google Font imports in the main CSS file because I didn't have that many. Today I added one that simply wouldn't render, either in Chrome or Firefox. I tried a different font - same problem.

Finally, I made a separate @import in another CSS file that gets loaded for several pages on the site (let's call it navbar_pages.css, for example) - this CSS gets included in the relevant pages via <link rel="stylesheet" type="text/css" href="/css/navbar_pages.css">, just like main.css does.

For some reason, having the @import in a separate CSS file solved the problem.

I suspect it is due to a limit on the number of fonts that can be called in a single @import call. More testing should be done to pin down the cause, but for now there is my workaround. If anyone has insights, please chime in with a comment.

Solution 15 - Html

It may not be a silver bullet, but fixe the issue on our site by moving the fontawesome css link to the bottom of our pages as well as weblike fix listed above.

Solution 16 - Html

If people are still having this problem before you try all the great solutions on here try using an !important tag in your css to see if that will fix it, as it did for me and I am not sure if the bug is the same as the old Chrome bug.

.faultyText {"Roboto Slab", Georgia, serif !important}

Solution 17 - Html

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionenodekciwView Question on Stackoverflow
Solution 1 - HtmlMegView Answer on Stackoverflow
Solution 2 - HtmlJohnAndrewsView Answer on Stackoverflow
Solution 3 - HtmlkjetilhView Answer on Stackoverflow
Solution 4 - HtmlAndrewView Answer on Stackoverflow
Solution 5 - HtmlNateView Answer on Stackoverflow
Solution 6 - HtmlConor O KellyView Answer on Stackoverflow
Solution 7 - HtmleMadView Answer on Stackoverflow
Solution 8 - HtmlSebastiaan OrdelmanView Answer on Stackoverflow
Solution 9 - Htmlb1naryView Answer on Stackoverflow
Solution 10 - HtmljimutyView Answer on Stackoverflow
Solution 11 - HtmlAkshayView Answer on Stackoverflow
Solution 12 - HtmlMarcGuayView Answer on Stackoverflow
Solution 13 - Htmluser5147563View Answer on Stackoverflow
Solution 14 - HtmlMentalistView Answer on Stackoverflow
Solution 15 - HtmlJohn RossitterView Answer on Stackoverflow
Solution 16 - HtmlNeil Philip WhiteheadView Answer on Stackoverflow
Solution 17 - HtmlTomaszView Answer on Stackoverflow