Archived topic
Add a Google Font (and Variants) to the Google Font List
5 replies · Started by twarrior on December 20, 2021
Hello,
I have followed https://docs.generatepress.com/article/customizing-the-google-font-list/ to add Red Rose Font
Add this with CodeSnippets:
add_filter( 'generate_typography_customize_list', 'tu_add_google_fonts' );
function tu_add_google_fonts( $fonts ) {
$fonts[ 'red_rose' ] = array(
'name' => 'Red Rose',
'variants' => array( '400', '500', '700' ),
'category' => 'sans-serif'
);
return $fonts;
}
I can see the Red Rose in the font lists, but I can not see any variants:

And if i select 700, i see this strange behaviour only in some letters:

Hi there,
Make sure you are following the instruction from this link: https://docs.generatepress.com/article/adding-local-fonts/
1. You don't need the PHP snippet to add the font to fonts list if you GP version is 3.1.0 or above (make sure you are using the new typography system), you just need to add the font name to the font family name field:https://www.screencast.com/t/DajKUtfYM
2. If your font uploaded and @font-face CSS installed correctly, the variants should be there.
Let me know if you need further assistance :)
thanks for replying, but I'm sorry but I don't understand you.
Why should I follow the "add a local font" tutorial https://docs.generatepress.com/article/adding-local-fonts/? Isn't it better to use the Google Fonts service?
Oh so you are not using local fonts? Sorry I misunderstood the question.
Then it's even easier :)
You don't need to use any PHP filter or CSS at all, you just need to enter the google font name in the typography system, I shot a small clip for you:
https://www.screencast.com/t/Gmu1nwHGVd
Let me know if this helps :)
Thanks you
RESOLVED!
Great!
You are welcome :)