[Support request] Adding Three Google Fonts

Home Forums Support [Support request] Adding Three Google Fonts

Home Forums Support Adding Three Google Fonts

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #1239946
    Mindy

    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!

    #1240641
    Mindy

    Bump; hopefully that’s okay to do πŸ™‚

    #1240833
    Tom
    Lead Developer
    Lead Developer

    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.

    #1240853
    Mindy

    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!

    #1241775
    Tom
    Lead Developer
    Lead Developer

    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?

    #1241793
    Mindy

    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:

    https://bit.ly/34Io819

    Thank you! πŸ™‚

    #1242207
    Tom
    Lead Developer
    Lead Developer

    Try with the first letter capitalized. So instead of cabin, try Cabin.

    #1242233
    Mindy

    Interesting- that made them work on edit page, but they are not showing properly for me on the updated live page.

    #1242249
    Tom
    Lead Developer
    Lead Developer

    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 πŸ™‚

    #1242777
    Mindy

    Okay, thank you Tom! πŸ™‚

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.