Site logo

[Resolved] Custom WOFF2 font not loading

Home Forums Support [Resolved] Custom WOFF2 font not loading

Home Forums Support Custom WOFF2 font not loading

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1856518
    Gabriele

    Hey guys!
    I’ve just followed this tutorial on how to add custom font https://docs.generatepress.com/article/adding-local-fonts/
    but, although I can choose it from the Customize/Typography settings, I don’t think it’s loading at all.

    Here is the code I have added to Simple CSS:

    @font-face {
        font-family: "Monty";
        src: url(public_html/wearefesta/wp-content/themes/generatepress/assets/fonts/Monty-Bold-Trial.woff2) format("woff2"),        url(public_html/wearefesta/wp-content/themes/generatepress/assets/fonts/Monty-Bold-Trial.woff) format("woff");  
        font-weight: bold;  
    }
    
    @font-face {
        font-family: "Monty";
        src: url(public_html/wearefesta/wp-content/themes/generatepress/assets/fonts/Monty-Light-Trial.woff2) format("woff2"),  url(public_html/wearefesta/wp-content/themes/generatepress/assets/fonts/Monty-Light-Trial.woff) format("woff");  
        font-weight: normal;  
    }

    and here is the PHP snippet I have created:

    add_filter( 'generate_typography_default_fonts', function( $fonts ) {
        $fonts[] = "Monty";
    
        return $fonts;
    } );

    Hope you can help with this!
    Cheers,
    G

    #1856642
    David
    Staff
    Customer Support

    Hi there,

    first off DONT add them to the Parent Themes folders as any changes you make will be lost when you update the Theme,

    You should use a Child Theme or add them to the Media Library as explained in the DOC:

    https://docs.generatepress.com/article/adding-local-fonts/

    Then you must ensure the url in your @font-face src is the exact full URL to the files. Including the HTTPS:: domain

    #1856682
    Gabriele

    Okay, I see!
    So I did that and it works now, thanks for your help David!
    Alwasy great!
    G

    #1856742
    David
    Staff
    Customer Support

    Really glad to hear that!

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