[Resolved] Adding Local Fonts

Home Forums Support Adding Local Fonts

  • This topic has 11 replies, 3 voices, and was last updated 1 year ago by David.
Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #1213409
    sporenborg

    HI,

    I tried to use your tutorial ‘Adding Local Fonts’ but something doesn’t work.

    I added your code:

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

    … to the GP child theme > functions.php – it didn’t work. Then I downloaded the suggested plugin ‘code snippets’ … the same. Can you pls tell me what I am doing wrong?

    Best regards

    #1213452
    Leo
    Staff
    Customer Support

    Hi there,

    Just to make sure, you’ve completed all the steps here?

    The snippet you used above is only to add it to the customizer.

    Let me know 🙂

    #1213454
    sporenborg

    Correct. I added the code to the customizer and added the code for @fontface to the style.css …

    #1213472
    Leo
    Staff
    Customer Support

    Sorry I forgot to provide the link to the article above.

    Is the font actually uploaded?
    https://docs.generatepress.com/article/adding-local-fonts/#uploading-our-font

    #1213474
    sporenborg

    Yes, it is. I used to follow this tutorial. If I enter the font-url it can be downloaded.

    #1218386
    David
    Staff
    Customer Support

    Hi there,

    when you say it didn’t work – was the Font available in the Customizer ?

    #1220480
    sporenborg

    no, the Font isn’t available in the Customizer. But is available in Elementor Pro which we use for the PAGES. GP we use for the blog. There it doesn’t work.

    Thats the code I added to the functions.php

    add_filter( 'generate_typography_default_fonts', function( $fonts ) {
        $fonts[] = 'XXXX-Light';
        $fonts[] = 'XXXX-Medium';
        $fonts[] = 'XXXX-Bold';
        $fonts[] = 'XXXX-Heavy';
    
    	
        return $fonts;
    } );

    Do you need any further code exemples?

    Thx!

    #1220574
    David
    Staff
    Customer Support

    That code is used to add the Font Names to the Typography list in the Customizer.
    They will appear just after the System Stack fonts and before the Google Fonts.

    If they are not displaying then there is an issue with your function.php

    If they are displaying you will need to add your fonts and @font-face CSS as explained here:

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

    #1228100
    sporenborg

    Thank you very much for your comments. I have – in my opinion – proceeded exactly as recommended by you. Yet it does not work. Nothing appears after the System Stack fonts and before the Google Fonts. Do you have any other idea?

    #1228376
    David
    Staff
    Customer Support

    Can you try adding the Code using the Code Snippets plugin ?

    https://en-gb.wordpress.org/plugins/code-snippets/

    #1230204
    sporenborg

    Hello David, you’re my hero! As usual, the problem was sitting in front of the monitor and in the rush it read the text only selectively. From the pagebuilders I was used to find the local fonts appearing before the system stack fonts. But you had written that they appear after the system stack fonts. I did not search there.

    For all those who also stumble across this thread, the hint: Finally, inserting the code

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

    to find here … https://docs.generatepress.com/article/adding-local-fonts/

    also works without the Code Snippet module. I try to work more and more with less plugins and reduce the use of pagebuilders since I use GP to increase the page speed.

    Thank you very much for your great support, which I will surely use a few more times.

    #1230845
    David
    Staff
    Customer Support

    Awesome – glad you got it resolved.

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