[Resolved] Force Locally Hosted Fonts

Home Forums Support [Resolved] Force Locally Hosted Fonts

Home Forums Support Force Locally Hosted Fonts

Viewing 15 posts - 1 through 15 (of 33 total)
  • Author
    Posts
  • #835699
    Simon

    Hey Guys,

    this should be fairly quick.

    I just followed the guide to locally host fonts.
    Fonts hosted /uploads/fonts/
    I referenced the fonts with the full url: https://www.domain.com/wp-content/uploads/fonts/lato-v14-latin-regular.eot
    And I have the settings in typrography -> body set as the uploaded font and its variants e.g. regular, italic, 700, 900

    Now i am just unsure if there is anything i need to do to force the fonts to load from my local hosted files???

    Did i miss something?

    Cheers,
    Simon

    #835718
    David
    Staff
    Customer Support

    Hi there,

    i can see lato 700, 900, italic and regular being called locally. But google fonts is still being used. Make sure that you select your local font in the Customizer as opposed to the one in the Google Font list.

    I assume you added the filter to display the fonts in the customizer ( as part of the article instructions states)

    #835807
    Simon

    Ahhh!!!

    I did have the php installed (set to: Only run in administration area (is that correct?))

    But hadn’t selected Lato under the “system fonts”, which i have done now. So i think it should all work not.

    Thanks so much for your help David. Much appreciated.

    Cheers,
    Simon

    #835949
    David
    Staff
    Customer Support

    That’s correct Admin only.
    Yep all looking good, no google fonts being loaded.

    Glad to be of help.

    #836011
    Simon

    Thanks very much again David.

    #836065
    David
    Staff
    Customer Support

    You’re welcome

    #836094
    Simon

    Ah Sorry David. I just purged all the caches, even disabled WPRocket. Cleared my browser cache and ran it in an incognito window. But I am still seeing the font loading from google…

    Any thoughts? is it happening for you?

    Cheers,
    Simon

    #836351
    David
    Staff
    Customer Support

    I see a couple of cached google font requests.
    Do you have any server caches? CloudFlare?

    You can forcibly remove them from the theme as well this topic:

    https://docs.generatepress.com/article/remove-google-fonts/

    #836413
    Simon

    Ah thats perfect. I guess I’ll do that and see what happens. Yeah I have cleared every cache there is multiple times, and they are still showing for me. Not sure how to tell if there cached or not…

    Thank you again.

    Cheers,
    Simon

    #836493
    David
    Staff
    Customer Support

    In the browser Developer tools > Network will show you where the request is coming from. If it says Cached then its the browser. If the file name looks like gobbledygook then its a cached file being served.

    Hope you figure it out πŸ™‚

    #836996
    Simon

    Haha, so thats how you spell gobbledygook πŸ™‚

    That is really useful to know regardless, i am sure i will use it countless times in the future.

    It seems everything has fixed itself, but it looks like maybe WPRocket is possibly preloading google fonts. I have contacted their support about that.

    Cheers,
    Simon

    #837158
    David
    Staff
    Customer Support

    haha – such a great word πŸ™‚

    #841277
    Simon

    Hi Guys,

    I returned to double check this, but it does appear to me that Generatepress is still making a call to google fonts. I also noted that in the font “typography” selector, when I refresh the page it goes back to the “Lato” google font instead of the “Lato” system font.

    I am fairly convinced it is GP loading the css file because if I change the fonts to being different weight, the css font file it calls also changes.

    I am using this code to laod the font:
    add_filter( ‘generate_typography_default_fonts’, function( $fonts ) {
    $fonts[] = ‘Lato’;

    return $fonts;
    } );

    Should i maybe be using this code instead?

    add_filter( ‘generate_typography_default_fonts’,’tu_add_system_fonts’ );
    function tu_add_system_fonts( $fonts ) {
    $fonts[] = ‘My Font Name’;
    return $fonts;
    }

    I am guessing maybe it has something to do with me trying to add a system font that is also in the google fonts?

    I also tried to add these but .i got an error when i tried to load both of them?
    add_action( ‘wp_enqueue_scripts’,’tu_remove_google_fonts’, 10 );
    function tu_remove_google_fonts() {
    wp_dequeue_style( ‘generate-fonts’ );
    }
    If you wish to remove Google Fonts from the customizer as well, you can use the PHP snippet below:

    add_action( ‘admin_init’, ‘tu_remove_google_fonts’ );
    function tu_remove_google_fonts() {
    add_filter( ‘generate_google_fonts_array’, ‘__return_false’ );
    }

    Cheers,
    Simon

    #841478
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Yes, it looks like GeneratePress is calling Google for the Lato font.

    Just to confirm, you’ve selected the “Lato” font within the “System fonts” area of your typography dropdowns, correct? Are you sure the Google Font version isn’t selected in any of your other typography dropdowns for another element?

    #841510
    Simon

    Hey Tom,

    Yeah thats correct I have selected the lato font under system fonts, however if i refresh the page, the google font is selected again…

    Yeah just double checked, inherit is selected in every other typography field.

Viewing 15 posts - 1 through 15 (of 33 total)
  • You must be logged in to reply to this topic.