- This topic has 9 replies, 2 voices, and was last updated 6 years ago by
Mindy.
-
AuthorPosts
-
April 15, 2020 at 7:22 am #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!April 15, 2020 at 12:56 pm #1240641Mindy
Bump; hopefully that’s okay to do 🙂
April 15, 2020 at 5:28 pm #1240833Tom
Lead DeveloperLead DeveloperHi 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.
April 15, 2020 at 6:13 pm #1240853Mindy
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!
April 16, 2020 at 8:53 am #1241775Tom
Lead DeveloperLead DeveloperCan you link me to a page where one of them is typed in as a Headline block font? Is the “Google font” toggle checked?
April 16, 2020 at 9:03 am #1241793Mindy
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! 🙂
April 16, 2020 at 3:40 pm #1242207Tom
Lead DeveloperLead DeveloperTry with the first letter capitalized. So instead of
cabin, tryCabin.April 16, 2020 at 4:25 pm #1242233Mindy
Interesting- that made them work on edit page, but they are not showing properly for me on the updated live page.
April 16, 2020 at 4:50 pm #1242249Tom
Lead DeveloperLead DeveloperHmm, Gotu only has
400weight, 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 🙂
April 17, 2020 at 5:35 am #1242777Mindy
Okay, thank you Tom! 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.