Site logo

Archived topic

local fonts not on all devices

13 replies · Started by Angie on October 27, 2021

Viewing posts 1–14 of 14

Hello!
I want to add two google fonts locally and I think I’ve done something wrong.
I followed your guide here: https://docs.generatepress.com/article/adding-local-fonts/

Now after updating I also used the new typography manager to define the local fonts. I then deleted the CSS code (font-face) > that solved the problem of loading time.

But still the fonts don’t show on all devices.

I always clear the cache before loading the site!

- I uploaded the fonts (Open Sans and Pathway Gothic) via ftp to: /wordpress/wp-content/themes/generatepress_child/fonts

- Using Snippets I added this code:

add_filter( 'generate_typography_default_fonts', function( $fonts ) {
    $fonts[] = 'Open Sans';
    $fonts[] = 'Pathway Gothic One';
	$fonts[] = 'Fontawesome Solid';

    return $fonts;
} );

I also removed Google Fonts from the site with this code (provided in this article: https://docs.generatepress.com/article/remove-google-fonts/)

add_action( 'wp_enqueue_scripts', function() {
    wp_dequeue_style( 'generate-fonts' );
} );
add_action( 'admin_init', function() {
    add_filter( 'generate_google_fonts_array', '__return_empty_array' );
} );

It seems to work with the font 'Pathway Gothic' for Headlines. But for the body 'Open Sans' is always replaced by Arial (on my mobile and on other devices, except the one I'm working on).

Please help me in any way!
Angie.

Hi Angie,

When I check your site using my computer, the body font is using Open sans.

But when I check on my iPhone, it does seem like using Arial, although I'm not very sure the 2 fonts look quite similar.

If you add Open sans in font manager, and toggle the google font button, use that font for the body.

Does the font display correctly on your mobile devices?

Let me know :)

Hi Ying,

thanks for checking.
after switching the google font button, it seems to work and use on all my devices (iphone, laptop and desktop) Open sans. Does this mean,

Question: does this still mean, I use the local version of the fonts? I also deactivated google fonts from the site as mentioned above. So I should be on the save side, or not?

Thank you very much!
Angie.

Hi there,

We need to update that Doc for GP 3.1 as you no longer need to add the Fonts to the Customizer list.
So you DON'T need this part:

https://docs.generatepress.com/article/adding-local-fonts/#adding-it-to-the-customizer

Instead you simply type the name of the Font into the Customizer > Typography > Font Manager, and make sure the Google font option is unselected.

As long as you have the Fonts loaded in your site and the @font-face CSS that references those fonts it should work.

If you can confirm those changes i can then take a look at whats going on :)

Hello David,
thank you. I did that now.
It works now, but loads again quite slowly (Loads Arial before it seems to find the custom fonts).
If you could look into this, I'd be glad!

best wishes, Angie.

Your local fonts still aren't loading as they are all 404ing and then the google fonts kick in.
Can you check the URL in your @font-face CSS is correct? I would set it to the full path to the font files.

Yes, I suspect that the paths are incorrect.
Does it make a difference for the paths where I enter the CSS?
Now I added it in the Costumizer, is it better to add it in the theme Editor? So both locations add code to the style.css?

You recommend adding the Font Face paths as full paths including https?

Thank you!
Angie

As long as the @font-face URLs are 100% match to the file location including the HTTPS then it doesn't matter where the CSS is added ( eg. in the Customizer > Additional CSS or the Child Theme Style sheet ).

Ok, for me this looks better. Could you check again!

Thank you sooo much!!
Angie.

90% there - looking much better.
I can still see one font requested from Google which is Open Sans.

Do you still have this snippet added?

add_action( 'wp_enqueue_scripts', function() {
    wp_dequeue_style( 'generate-fonts' );
} );

Yes, this snippet was still added. I deleted it now.

What about that?

Thank you, Angie.

Hi Angie,

Just checked your site, there's no request for google fonts now :)

I guess it's all good on your end?

Great! Thank you for the support!
Angie.

No problem :)

This archived topic is closed to new replies.