Site logo

Archived topic

Adding Local Fonts

11 replies · Started by sporenborg on March 28, 2020

Viewing posts 1–12 of 12

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

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 :)

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

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

Hi there,

when you say it didn't work - was the Font available in the Customizer ?

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!

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/

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?

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.

Awesome - glad you got it resolved.

This archived topic is closed to new replies.