- This topic has 20 replies, 5 voices, and was last updated 4 years ago by
Ying.
-
AuthorPosts
-
April 26, 2021 at 6:39 pm #1750175
troyw
Hi team,
I have tried to follow your instructions to import a custom font, but they do not explain how to do this with a non-google font.
https://docs.generatepress.com/article/adding-local-fonts/As they only explain how to import Google Fonts, they skip how to obtain the font link url under your section ‘Using@fontface’
So I have added the following font files to my child-theme using then ftp method and adding a new folder called ‘fonts’.
glassure-webfont.woff
glassure-webfont.woff2
glassure.ttf
glassure.otfAs these are not google fonts, what do i do next to get this font added to my website?
Thanks
April 26, 2021 at 7:13 pm #1750195Elvin
StaffCustomer SupportHi there,
That documentation applies to ALL fonts, not just Google fonts. You can do the guide with the fonts you’ve specified.
The basic idea is to upload the font files to the site and write its appropriate CSS importation(@font-face) for use on the site. 🙂
April 26, 2021 at 7:15 pm #1750196troyw
Do you have any instructions on how to write the appropriate css?
I have added this CSS to the stle sheet and still nothing happens@font-face {
font-family: glassure;
src: url(https://www.******.com.au/wp-content/themes/*******/fonts/glassure.ttf);
font-weight: normal;
}April 26, 2021 at 7:27 pm #1750200Elvin
StaffCustomer SupportIt’s the same one you see here:
https://docs.generatepress.com/article/adding-local-fonts/#using-font-faceWe just change the file path and the font-family name.
Example:
@font-face { font-family: 'Glassure'; font-style: normal; font-weight: 300; src: url(https://yourdomain.com/your/path/to/the/font/file/glassure-webfont.woff2) format('woff2'); }This is just an example. I’m not exactly sure what’s appropriate for the specific properties for the files you’ve specified.
Note: If this is a licensed font, the @font-face or @import code usually comes with it after purchase. Example:
https://creativemarket.com/yusril.muhtadi/3653080-Glassure-Typeface-version-1.0?u=beacon9688&utm_source=Link&utm_medium=CM+Social+Share&utm_campaign=Product+Social+Share&utm_content=Glassure+Typeface+version+1.0&ts=201905April 26, 2021 at 7:29 pm #1750203troyw
Is this what you mean;
@font-face {
font-family: ‘glassureregular’;
src: url(‘glassure-webfont.woff2’) format(‘woff2’),
url(‘glassure-webfont.woff’) format(‘woff’);
font-weight: normal;
font-style: normal;}
April 26, 2021 at 7:38 pm #1750206troyw
So I have added this to the stylesheet but still font not appearing;
@font-face {
font-family: ‘glassureregular’;
src: url(https://www.*****.com.au/wp-content/themes/******/fonts/glassure-webfont.woff2′) format(‘woff2′),
url(https://www.*****.com.au/wp-content/themes/*****/fonts/glassure-webfont.woff’) format(‘woff’);
font-weight: normal;
font-style: normal;}
April 26, 2021 at 7:53 pm #1750215Elvin
StaffCustomer SupportAre you trying to add it on the customizer settings?
If so, you’ll have to do that with PHP.
Example:
add_filter( 'generate_typography_default_fonts', function( $fonts ) { $fonts[] = 'glassureregular'; return $fonts; } );April 26, 2021 at 7:55 pm #1750217troyw
I am adding it to the Child Theme Style Sheet.
I just added the above code to the style sheet too and still nothing?April 26, 2021 at 8:05 pm #1750220Elvin
StaffCustomer SupportCan you link us to the site in question to check? So I can inspect if there are issues w/ the importation.
April 26, 2021 at 8:07 pm #1750222troyw
See private info
April 26, 2021 at 8:20 pm #1750227Elvin
StaffCustomer SupportAh I see now.
A few things:
https://share.getcloudapp.com/04uAyG99You’ve added things within Appearance > Customize > Additional CSS.
The filter part is PHP. It has to be added on a child theme’s functions.php or Code Snippets plugin.
The @font-face part has wrong URL. Also, its a duplicate entry because you already have one on your style.css within the child theme. Just remove it and keep the one on the child theme.
Note: The importation from the child theme actually works, you just need to fix the PHP.
See this: https://share.getcloudapp.com/12uARx6Z
April 26, 2021 at 8:34 pm #1750240troyw
That seems to have fixed it.
Thanks Elvin.April 26, 2021 at 8:38 pm #1750242Elvin
StaffCustomer SupportNo problem. Glad you got it fixed. 🙂
April 4, 2022 at 8:56 am #2177732Sílvia
Hello,
I have the same problem that troyw had trying to ad custom fonts (not Google).
I’ve written the css code and also added the php code through the snippets plugin but it still doesn’t seem to work.
Any idea?Thanks in advance,
SilviaApril 4, 2022 at 9:14 am #2177744David
StaffCustomer SupportHi there,
what part does not work ?
-
AuthorPosts
- You must be logged in to reply to this topic.