Archived topic
Adding Three Google Fonts
9 replies · Started by Mindy on April 15, 2020
Hello, I am trying to add three fonts, but they are not working.
I added and activated this using code snippets:
add_filter( 'generate_typography_customize_list', 'tu_add_google_fonts' );
add_filter( 'generate_google_fonts_array', 'tu_add_google_fonts' );
function tu_add_google_fonts( $fonts ) {
$fonts[ 'cabin' ] = array(
'name' => 'Cabin',
'variants' => array( '400', '500', '700' ),
'category' => 'sans-serif'
);
$fonts[ 'gotu' ] = array(
'name' => 'Gotu',
'variants' => array( '400' ),
'category' => 'sans-serif'
);
$fonts[ 'handlee' ] = array(
'name' => 'Handlee',
'variants' => array( '400' ),
'category' => 'sans-serif'
);
return $fonts;
}
However, the fonts do not work on the page. (using Generateblocks headline block if it matters)
Thanks for any help!
Bump; hopefully that's okay to do :-)
Hi there,
This should work:
add_filter( 'generate_typography_customize_list', function( $fonts ) {
$fonts[ 'cabin' ] = array(
'name' => 'Cabin',
'variants' => array( '400', '500', '700' ),
'category' => 'sans-serif'
);
$fonts[ 'gotu' ] = array(
'name' => 'Gotu',
'variants' => array( '400' ),
'category' => 'sans-serif'
);
$fonts[ 'handlee' ] = array(
'name' => 'Handlee',
'variants' => array( '400' ),
'category' => 'sans-serif'
);
return $fonts;
} );
They should be available inside the list in the Customizer within the Google fonts area.
Hi Tom,
Two of the fonts now appear in the customizer using this code you have suggested. "Gotu" does not appear. Also, they appear in the customizer, but when I use the "headline" Generateblock, the fonts do not work the way other Google fonts work when typed in.
Thank you for your help!
Can you link me to a page where one of them is typed in as a Headline block font? Is the "Google font" toggle checked?
Sure- here is a page that has each font I would like in their own containers, each using the headline block, and with the font typed in and "google font" toggled:
Thank you! :)
Try with the first letter capitalized. So instead of cabin, try Cabin.
Interesting- that made them work on edit page, but they are not showing properly for me on the updated live page.

Hmm, Gotu only has 400 weight, but you're loading 700. This may be a bug in GenerateBlocks that we need to fix, as we only try to load the variants we need to in order to reduce page size.
I'll take a look :)
Okay, thank you Tom! :)