[Resolved] generate_typography_customize_list

Home Forums Support [Resolved] generate_typography_customize_list

Home Forums Support generate_typography_customize_list

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #580410
    NBC

    I’m attempting to use the generate_typography_customize_list function to add the three parts of the Barlow family from Google Fonts to the Customizer’s font list.

    I’m following the instructions here.

    I’ve added the relevant code to my child theme’s functions.php file. The typefaces do not show up in the Customizer, however.

    I’m developing this site under localhost, so no site link to share.

    Here’s the code.

    add_filter( 'generate_typography_customize_list', 'tu_add_google_fonts' );
    function tu_add_google_fonts( $fonts ) {
    	$fonts[ 'Barlow' ] = array( 
    		'name' => 'Barlow',
    		'variants' => array('100', '100i', '200', '200i',  '300', '300i', '400', '400i', '500', '500i', '600', '600i', '700', '700i', '800', '800i', '900', '900i' ),
    		'category' => 'sans-serif'
    	);
    	$fonts[ 'Barlow Semi Condensed' ] = array( 
    		'name' => 'Barlow Semi Condensed',
    		'variants' => array('100', '100i', '200', '200i',  '300', '300i', '400', '400i', '500', '500i', '600', '600i', '700', '700i', '800', '800i', '900', '900i' ),
    		'category' => 'sans-serif'
    	);
    	$fonts[ 'Barlow Condensed' ] = array( 
    		'name' => 'Barlow Condensed',
    		'variants' => array('100', '100i', '200', '200i',  '300', '300i', '400', '400i', '500', '500i', '600', '600i', '700', '700i', '800', '800i', '900', '900i' ),
    		'category' => 'sans-serif'
    	);
    	
    	return $fonts;
    }
    #580431
    Leo
    Staff
    Customer Support

    Hi there,

    I copied and paste your code in Code Snippets and it worked for me.

    Did you check at the bottom of the list and or use the search?

    Let me know.

    #581113
    NBC

    Hi, Leo:

    I searched for other discussion threads that covered this topic, as well as the documentation itself. The solution I implemented comes straight out of the GP documentation. Added to the functions.php file of my child theme, the code has no impact whatsoever.

    #581118
    Leo
    Staff
    Customer Support

    There is a bit of misunderstanding πŸ™‚

    I meant search in the customizer typography list.

    I did test your code and it worked for me:
    http://www.screencast.com/t/09GNNU2Y

    #581155
    NBC

    Hi, Leo:

    I tried the Code Snippets plug-in. Turns out it adds the typefaces to the end of the list. I was looking for them to appear alphabetized in with the rest of the list.

    However, the style list does not appear. All three Barlow typeface families include 9 weights. The Font Family list of styles does not appear in the Customizer. I can select normal and (what looks like a fake) bold, but that’s it.

    #581337
    Tom
    Lead Developer
    Lead Developer

    Can you try this instead?:

    add_filter( 'generate_typography_customize_list', 'tu_add_google_fonts' );
    function tu_add_google_fonts( $fonts ) {
    	$fonts[ 'barlow' ] = array( 
    		'name' => 'Barlow',
    		'variants' => array('100', '100i', '200', '200i',  '300', '300i', '400', '400i', '500', '500i', '600', '600i', '700', '700i', '800', '800i', '900', '900i' ),
    		'category' => 'sans-serif'
    	);
    	$fonts[ 'barlow_semi_condensed' ] = array( 
    		'name' => 'Barlow Semi Condensed',
    		'variants' => array('100', '100i', '200', '200i',  '300', '300i', '400', '400i', '500', '500i', '600', '600i', '700', '700i', '800', '800i', '900', '900i' ),
    		'category' => 'sans-serif'
    	);
    	$fonts[ 'barlow_condensed' ] = array( 
    		'name' => 'Barlow Condensed',
    		'variants' => array('100', '100i', '200', '200i',  '300', '300i', '400', '400i', '500', '500i', '600', '600i', '700', '700i', '800', '800i', '900', '900i' ),
    		'category' => 'sans-serif'
    	);
    	
    	return $fonts;
    }

    Let me know πŸ™‚

    #581352
    NBC

    Hi, Tom:

    Yes, that did the trick. I’d love to know why!

    Thanks for the invaluable assistance!

    #581353
    Tom
    Lead Developer
    Lead Developer

    The first instance of the names need to be lowercase and separated by underscores.

    Glad I could help! πŸ™‚

    #581432
    NBC

    Thanks, Tom! I learn something every day.

    #581708
    Tom
    Lead Developer
    Lead Developer

    You’re welcome! πŸ™‚

    #2544355
    David

    Hi Tom, is the ‘generate_typography_customize_list’ function still the most up-to-date way to add Google fonts programatically? Thanks

    #2545113
    David
    Staff
    Customer Support

    Hi David,

    i passed your other support topic over to Tom to take a look.

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