- This topic has 15 replies, 4 voices, and was last updated 5 years, 4 months ago by
Elvin.
-
AuthorPosts
-
December 3, 2020 at 5:55 am #1565589
Chitika
I would like to host the Google fonts I’m using for my site locally on my server.
In page speed tests, I see that loading these fonts externally is causing some increase in page load time.
Can you tell me how to implement it with GP.December 3, 2020 at 5:57 am #1565592Elvin
StaffCustomer SupportHi,
You can check this brief documentation on how to add local fonts to your site.
https://docs.generatepress.com/article/adding-local-fonts/December 4, 2020 at 12:27 am #1566846Chitika
Hi,
I have added a font – “Source Sans Pro” on my site for the body section as you said.
Now, in the Typography setting, I have selected it as system font.In the Font Family section, I see 200, 200 italic, etc. kind of items.
Are they all required to be included. Or else I can delete them.December 4, 2020 at 12:59 am #1566867Elvin
StaffCustomer SupportIn the Font Family section, I see 200, 200 italic, etc. kind of items.
Are they all required to be included. Or else I can delete them.You can remove them if you don’t need them. 🙂
December 4, 2020 at 1:28 am #1566879Chitika
Few questions.
In the Font Family section, I see 200, 200 italic, etc. kind of items.
Are they all required to be included. Or else I can delete them.You can remove them if you don’t need them. 🙂
1. If I delete them, can i get all of them back easily or do I need to add them individually.
2. Also, since I don’t need the Google Fonts now, how to disable them.
3. From personal experience, do you think hosting Google fonts locally is a good idea.December 4, 2020 at 1:47 am #1566894Baz
Hi Chitika,
I recently read this article by WP Rocket: https://wp-rocket.me/blog/self-hosting-google-fonts/
From the article, it seems to suggest there is negligible difference in hosting fonts locally vs linking to google fonts.
Don’t know if the GP team would agree with that 🙂
December 4, 2020 at 2:41 am #1566959Elvin
StaffCustomer SupportFrom the article, it seems to suggest there is negligible difference in hosting fonts locally vs linking to google fonts.
“Neglible” is relative to how nitpicky a person is. Some people are bothered by the 0.02 second difference. lol.
Kidding aside, that’s actually true in some cases where the font query is well specified. But there are also sites where locally hosting fonts cuts the loading time by half as google font’s render-blocking CSS can be an issue. And this is related to CLS issues reported by Google PSI on some sites.
December 4, 2020 at 2:49 am #1566964Baz
Ha ha, 0.02 seconds improvement is the holy grail for some people lol.
I myself prefer to use the most popular google fonts (e.g. Roboto), as there is a distinct possibility that your visitor’s browser has already cached that font from surfing other websites.
If you’re going to use one of the more fancier fonts, then hosting locally would be beneficial.
Thanks Elvin.
December 9, 2020 at 6:12 pm #1573713Shuhui
Hi all,
sorry to jump in this conversation. I was also looking to host my fonts, but, following your article, when uploading the fonts to the Media Library (after adding the php code), the .tff files still cannot be uploaded “for security reasons”. All the other files type are uploaded without a problem.
Is this an error you can reproduce? Or have an idea what could be causing it?
Thanks a lotDecember 9, 2020 at 7:21 pm #1573752Elvin
StaffCustomer SupportHi all,
sorry to jump in this conversation. I was also looking to host my fonts, but, following your article, when uploading the fonts to the Media Library (after adding the php code), the .tff files still cannot be uploaded “for security reasons”. All the other files type are uploaded without a problem.
Is this an error you can reproduce? Or have an idea what could be causing it?
Thanks a lotHi @Clemence,
If WordPress doesn’t
.tfffile uploads, you’ll have to add in a snippet that allows it.Example:
add_filter('upload_mimes', 'add_custom_upload_mimes'); function add_custom_upload_mimes($existing_mimes) { $existing_mimes['ttf'] = 'application/x-font-ttf'; return $existing_mimes; }December 9, 2020 at 7:30 pm #1573758Shuhui
Hi Elvin,
Thanks for your fast reply. What I am saying is, even with the php snippet (the one you gave me here or the one we can find in the GP article), it still doesn’t work. On my side at least.
December 10, 2020 at 3:24 pm #1575004Elvin
StaffCustomer SupportHi,
Can you try checking your file here for it’s mime type?
https://wp-check-mime-type.com/It also provides the snippet when you check.
If it still has issues, can you link us to the .ttf file? To test on other servers if it works.
Let us know.
December 10, 2020 at 10:14 pm #1575333Shuhui
Yup still doesn’t work 🙁
I downloaded the files for Montserrat from this website, for regular, italic, 700 and 700 italic.Cheers
December 10, 2020 at 10:55 pm #1575353Elvin
StaffCustomer SupportStrange.
If you have access to FTP, you can edit your site’s
wp-config.phpand set this:define('ALLOW_UNFILTERED_UPLOADS', true);This allows ALL files to be uploaded. After setting this, you should be able to upload your .TTF or any file.
Note: It is not recommended to keep this setting open as it exposes your site to potential threats. After uploading your file, make sure to disable this again.
Alternatively, try using plugins that lets you upload your font files.
December 10, 2020 at 10:58 pm #1575357Shuhui
Sadly I don’t have access to FTP. Thanks for your help!
-
AuthorPosts
- You must be logged in to reply to this topic.