[Support request] Adding Google Font not working

Home Forums Support [Support request] Adding Google Font not working

Home Forums Support Adding Google Font not working

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #1368457
    Andy

    Hi,
    I’m trying to add the google Manrope font (https://fonts.google.com/specimen/Manrope) to the font list but its not displaying. Following the documentation I’ve added the following script to my child theme functions file:

    add_filter( 'generate_typography_customize_list', 'tu_add_google_fonts' );
    function tu_add_google_fonts( $fonts ) {
    	$fonts[ 'manrope' ] = array( 
    		'name' => 'Manrope',
    		'variants' => array( '300', '400', '500', '600', '700' ),
    		'category' => 'sans-serif'
    	);
    
    	return $fonts;
    }

    Tried purging cache but nothing has helped.

    Any help appreciated,

    Thanks,

    Andy

    #1368534
    David
    Staff
    Customer Support

    Hi there,

    that function should work.
    Can you try adding it using the Code Snippets plugin – if it still isn’t displaying in the Customizer then something else must be conflicting.

    #1368553
    Andy

    Hmmm, tried adding it to the snippets plugin and it deactivated it giving this error:

    The snippet has been deactivated due to an error on line 3:
    
    Cannot redeclare function tu_add_google_fonts.
    #1368564
    David
    Staff
    Customer Support

    That means the tu_add_google_fonts function name is already being used.
    Change both instances in your above function to something unique:

    e.g

    manrope_add_google_font

    #1368762
    Andy

    Hmmm, this is very odd. I changed the script as you suggested and I can actually see the font is being loaded in the source code but it’s still not available in the Customizer or any Gutenburg Blocks including GenerateBlocks.

    This is a new build so hardly has any plugins installed. I’ve even disabled Varnish Cache for the application but it hasn’t helped.

    I’ve edited my initial post and included the URL to the site.

    #1368997
    Andy

    I think it must have been some kind of cacheing issue as the fonts are loading now.

    #1369331
    David
    Staff
    Customer Support

    Glad to hear that

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