- This topic has 7 replies, 3 voices, and was last updated 7 years, 8 months ago by
Tom.
-
AuthorPosts
-
July 7, 2018 at 3:23 pm #618211
igor96
Hi!
I’m trying to add some local fonts.
I did all that is described here:
https://docs.generatepress.com/article/adding-local-fonts/
For example: I add lobster font to wp-content/themes/generatepress_child/fonts/lobster folder.
Edit my child theme functions.php and style.css.@font-face:
/* lobster-regular – cyrillic_latin */
@font-face {
font-family: ‘Lobster’;
font-style: normal;
font-weight: 400;
src: url(‘https://mysite.com/wp-content/themes/generatepress_child/fonts/Lobsterlobster-v20-cyrillic_latin-regular.eot’); /* IE9 Compat Modes */
src: local(‘Lobster Regular’), local(‘Lobster-Regular’),
url(‘https://mysite.com/wp-content/themes/generatepress_child/fonts/Lobsterlobster-v20-cyrillic_latin-regular.eot?#iefix’) format(’embedded-opentype’), /* IE6-IE8 */
url(‘https://italeen.com/wp-content/themes/generatepress_child/fonts/Lobsterlobster-v20-cyrillic_latin-regular.woff2’) format(‘woff2’), /* Super Modern Browsers */
url(‘https://mysite.com/wp-content/themes/generatepress_child/fonts/Lobsterlobster-v20-cyrillic_latin-regular.woff’) format(‘woff’), /* Modern Browsers */
url(‘https://mysite.com/wp-content/themes/generatepress_child/fonts/Lobsterlobster-v20-cyrillic_latin-regular.ttf’) format(‘truetype’), /* Safari, Android, iOS */
url(‘https://mysite.com/wp-content/themes/generatepress_child/fonts/Lobsterlobster-v20-cyrillic_latin-regular.svg#Lobster’) format(‘svg’); /* Legacy iOS */
}code added to functions.php:
/** Montserrat, philosopher, lobster, marck script, pacifico */
add_filter( ‘generate_typography_default_fonts’, ‘tu_add_local_fonts’ );
function tu_add_local_fonts( $fonts ) {
$fonts[] = ‘Montserrat’;
$fonts[] = ‘Philosopher’;
$fonts[] = ‘Lobster’;
$fonts[] = ‘Marck Script’;
$fonts[] = ‘Pacifico’;return $fonts;
}BUT no one of the added fonts work. I can’t find them in customizer (i purge all my cache too). I can’t understant where is the problem…
Can you help me?July 7, 2018 at 9:08 pm #618331Tom
Lead DeveloperLead DeveloperWhen you copy the URLs from your
@font-facesrc, does it download the font? Or does it go to a 404? It looks like you might be missing a/afterLobster?That function should add the fonts to the Customizer. They should be at the bottom of the “System fonts” section, right above the “Google fonts” heading.
July 8, 2018 at 3:55 am #618441igor96
Hi Tom!
Yes, I missing / after Lobster.. I correct it but te problem persist.
And yes: when I go to @font-face url it download the font.
Any other suggestions to solve this issue?July 8, 2018 at 9:05 am #618657Tom
Lead DeveloperLead DeveloperSo the issue now is that the fonts aren’t displaying in the Customizer? How are you adding the PHP? In your child theme functions.php?
July 8, 2018 at 1:47 pm #618781igor96
Yes, thhey aren’t displaying in the Customizer.
I add this code to functions.php of my child theme:
/** Montserrat, philosopher, lobster, marck script, pacifico */
add_filter( ‘generate_typography_default_fonts’, ‘tu_add_local_fonts’ );
function tu_add_local_fonts( $fonts ) {
$fonts[] = ‘Montserrat’;
$fonts[] = ‘Philosopher’;
$fonts[] = ‘Lobster’;
$fonts[] = ‘Marck Script’;
$fonts[] = ‘Pacifico’;return $fonts;
}I create some folder for fonts:
content/themes/generatepress_child/fonts/lobster
content/themes/generatepress_child/fonts/montserrat
content/themes/generatepress_child/fonts/philosopher
content/themes/generatepress_child/fonts/pacifico
content/themes/generatepress_child/fonts/marck script
and I add the font’s files inside them.I edit the style.css (child theme) file and add the @font-face.
July 8, 2018 at 11:43 pm #618955Leo
StaffCustomer SupportHey! Tom’s wife is in labor, he will get to this topic as soon as he can 🙂
July 9, 2018 at 12:34 am #618981igor96
🙂 Congratulations! Tanti auguri from Italy Tom!
PS: Don’t worry, I can wait.July 9, 2018 at 8:45 am #619400Tom
Lead DeveloperLead DeveloperThank you!
Any chance you can send me temporary admin login details so I can take a look? If so, you can send it through this form: https://generatepress.com/contact
Be sure to mention this topic 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.