• northstatehillbilly

    (@northstatehillbilly)


    Hi there,

    I just launched my website MooseNotes.com last night and am having some Google Fonts problems:

    1) The main body font is Lora, a beautiful serif. Everything else is Ubuntu. Sometimes when I refresh a page, Google Fonts pulls in Lora correctly, but the titles, nav links and section headers that are set to Ubuntu, load as a generic serif.

    I’m not sure why this happens. We have lots of internet hangups since we’re rural, but this just happened when I refreshed a page, and the internet is working just fine. This breaks my design, since fonts are my primary design element

    2) My Google Fonts are loaded via the stylesheet. I’ve read it’s best to place them in the functions file, but I’m seeing different comments on problems doing this correctly. If loading them via functions.php is best, how do I do this correctly?

    3) In my first blog post, I use italics a couple of times. It’s not using the italics versions of Lora and instead seems to be defaulting to a generic serif. I added the italics option to my stylesheet, so I don’t understand why it’s not working.

    Thank you for any help you can give me!

Viewing 15 replies - 1 through 15 (of 15 total)
  • Thread Starter northstatehillbilly

    (@northstatehillbilly)

    Here’s some more information for you:

    Here’s what I’m noticing, and I don’t know if this is part of the problem:

    In the Safari developer tool, I can see two error messages. One says this:
    “Did not parse stylesheet at ‘https://moosenotes.com/wp-content/themes/moose?ver=cd9b96051512f036e7eb10bffa428d46’ because non CSS MIME types are not allowed in strict mode.”

    The other error message is this:

    “Failed to load resource: The network connection was lost.” On the far right of this text is this link: https://fonts.gstatic.com/s/ubuntu/v8/sVvvcJDRTINJla2R4XwPVevvDin1pK8aKteLpeZ5c0A.ttf

    I’m not sure what any of this means.

    I load Google Fonts via my stylesheet. I’ve read it’s best to put them in functions.php, but I’m not sure how best to do this. It seems some people aren’t doing this correctly, from what I’ve seen in different blog posts.

    I know when Google Fonts is loading, it may display the fallback font, which I’ve set to ‘serif,’ and that’s the font I’m seeing. But probably half of the time, Ubuntu is not loading at all.

    Do you have any idea why this keeps happening? Thank you!

    MarkRH

    (@markrh)

    I also see the error in Firefox: 15:43:34.736 The stylesheet https://moosenotes.com/wp-content/themes/moose/?ver=cd9b96051512f036e7eb10bffa428d46 was not loaded because its MIME type, "text/html", is not "text/css".1 moosenotes.com

    I do not have problems loading the fonts. In my case it is loading: https://fonts.gstatic.com/s/ubuntu/v8/_aijTyevf54tkVDLy-dlnFtXRa8TVwTICgirnJhmVJw.woff2 and not a .ttf file.

    Firefox 41.0.2 in Windows 7 Pro 64bit.

    tech55541

    (@tech55541)

    Thread Starter northstatehillbilly

    (@northstatehillbilly)

    Thanks, Mark. It doesn’t happen all the time. I can work on my site all day and do multiple refreshes and everything is fine. Then all of a sudden Ubuntu won’t load and it takes a dozen or more refreshes to make it load.

    David_G

    (@questas_admin)

    Here is another way to add google fonts without the use of a plugin or anything else. Place this snippet in your child theme “functions.php” file. Replace FONT1|Font2 with your fonts. Notice there is a pipe | separating the fonts.

    // Add Google Font
    add_action( 'wp_enqueue_scripts', 'my_google_font' );
    function my_google_font() {
        wp_enqueue_style( $handle = 'my-google-font', $src = 'https://fonts.googleapis.com/css?family=FONT1|Font2', $deps = array(), $ver = null, $media = null );
    }
    Thread Starter northstatehillbilly

    (@northstatehillbilly)

    I’ve never seen this done as a function before. Thank you!

    David_G

    (@questas_admin)

    You won’t see the google fonts in your editor, just assign another WP font and change it in the text editor. That seems to be the only limitation to using the enqueue script.

    Thread Starter northstatehillbilly

    (@northstatehillbilly)

    tech55541, somehow I didn’t see your message to me. Thank you for the links.

    Someone on Twitter gave me a link to this:

    https://developer.mozilla.org/en/docs/Incorrect_MIME_Type_for_CSS_Files

    I’m chatting with my hosting company to see if MIME error and font not loading could be a server problem. Meanwhile, I’ll browse the links you gave me.

    I’ll post back here when a solution is found.

    tech55541

    (@tech55541)

    OK, let me know if you have questions.
    Can i ask what hosting company you are with? That might help in the research with your problem.

    Good Luck.

    MarkRH

    (@markrh)

    I think your server is giving the correct MIME type for .CSS files as other .CSS file load fine with the correct type. The problem is, this request has no extension:

    22:33:57.389 The stylesheet https://moosenotes.com/wp-content/themes/moose/?ver=cd9b96051512f036e7eb10bffa428d46 was not loaded because its MIME type, "text/html", is not "text/css".1 moosenotes.com

    As such it will revert to the default of text/html.

    Here’s the code loading it:

    <link rel='stylesheet' id='dashicons-style-css'  href='https://moosenotes.com/wp-content/themes/moose?ver=cd9b96051512f036e7eb10bffa428d46' type='text/css' media='all' />

    You also have this:

    <link rel='stylesheet' id='dashicons-css'  href='https://moosenotes.com/wp-includes/css/dashicons.min.css?ver=cd9b96051512f036e7eb10bffa428d46' type='text/css' media='all' />

    It makes me wonder if this extra ‘dashicons-style-css’ is some extra thing added by your theme or some plugin.

    Hmmm…

    Thread Starter northstatehillbilly

    (@northstatehillbilly)

    I’m not sure what you mean by extension, but thank you for looking into this for me!

    I created my own follow icons using Fontello and a font file. You can see them at the bottom of my website. Dashicons must be coming from the Genesis child theme I used to build my own child theme. I used Eleven40Pro.

    I don’t use Dashicons in my website, but maybe they’re used in the WordPress dashboard?

    SiteGround is my hosting company. They did a thorough search for the problem and couldn’t find anything. They want to recreate the problem and say it’s hard to fix when they can’t replicate it. But you can see the error message. I followed one suggestion to add a line of code to the .htaccess file and it didn’t remove the error, so I removed that line.

    I added this: AddType text/css .css

    I deactivated all plugins, one by one, and the error message still shows. And just now the Ubuntu font didn’t load when I refreshed the page, so for me anyway, the design is broken since it’s now using the default serif. It’s when the font doesn’t load that the second error message appears.

    Back to Dashicons … any thoughts on how they could be the source of this problem?

    MarkRH

    (@markrh)

    What I meant by extension is that the MIME type the server uses is based upon the file’s extension, for example “style.css” will be served as text/css where .css is the extension.

    In that one request there is no file extension for the server to match a MIME type against so it just does the default of text/html.

    https://moosenotes.com/wp-content/themes/moose?ver=cd9b96051512f036e7eb10bffa428d46 has no .css extension in it.

    The dashicons thing is separate from the Ubuntu font not loading sometimes.

    Thread Starter northstatehillbilly

    (@northstatehillbilly)

    So something is causing the missing file extension problem. It’s because the extension isn’t there that the font isn’t loading properly, correct? Or is that related to the Dashicons?

    Only the Ubuntu font is having the problem. When a page on my site loads, the other fonts load quickly and Ubuntu comes second. I removed Google Fonts from the stylesheet and enqueued them in the functions file, and this made a noticeable difference in load time, but Ubuntu still loads last.

    It’s such an odd problem. I like the detective work, but at this point it’s over my head. I’m not sure what else to do.

    Thread Starter northstatehillbilly

    (@northstatehillbilly)

    Mark, my hosting company just did another search for the error and determined that their server is giving the correct MIME type for .CSS files, just like you said.

    I’m glad to know that. It helps rule out that possibility.

    They were also able to recreate the error and could see the error message and the generic serif font. When the Ubuntu font doesn’t load, a second error message appears indicating the server timed out trying to load the font.

    Could those be two different problems? I just assumed they were related.

    Thread Starter northstatehillbilly

    (@northstatehillbilly)

    Mark!

    I was doing some work in my functions file, when I discovered the enqueued dashicons. I vaguely remember adding this for a test project last year. So I removed it, refreshed everything, and the dang error that kept showing up in the develop tool disappeared.

    I’m so glad for your wonderful insight and detective work. Thank you so much.

    I’m not sure if that’s what was causing the Google Font load problem. You mentioned that may have been a separate issue. So I’ll have to wait for the problem to happen again and see if I can figure it out.

    But thank you so much!!

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘Google Fonts not loading properly’ is closed to new replies.