- This topic has 3 replies, 2 voices, and was last updated 3 years, 11 months ago by
Tom.
-
AuthorPosts
-
June 18, 2019 at 3:36 am #933129
Lisa
**** Amendment – The font is now showing in the GeneratePress font list. but this code is showing on the front end
@import url(//fonts.googleapis.com/earlyaccess/opensanshebrew.css); (this is showing on the front end)ALSO – how do I add the second font – Open sans condensed Hebrew?
****I am struggling to add the font Open Sans Hebrew and Open Sans Condensed Hebrew to the GeneratePress theme.
This font does appear in Elementor font list but not in the GeneratePress font list.
I found several references to this in the forum from 2 years ago but was unable to decipher the correct way to do it.
This font still sits in ‘Early Access’ and not in the main google fonts library.This is what I have added to Simple CSS.
@import url(//fonts.googleapis.com/earlyaccess/opensanshebrew.css); (this is showing on the front end)
body {font-family: ‘Open Sans Hebrew’, sans-serif;}and this code to “Code Snippets’
add_filter( ‘generate_typography_customize_list’, ‘tu_add_google_fonts’ );
function tu_add_google_fonts( $fonts ) {
$fonts[ ‘open_sans_hebrew’ ] = array(
‘name’ => ‘Open Sans Hebrew’,
‘variants’ => array( ‘400’, ‘500’, ‘700’ ),
‘category’ => ‘serif’
);return $fonts;
}This is not working for me.
June 18, 2019 at 6:46 am #933320Tom
Lead DeveloperLead DeveloperIf the font isn’t in the Google Fonts library, you’ll want to use this filter:
add_filter( 'generate_typography_default_fonts', function( $fonts ) { $fonts[] = 'Open Sans Hebrew'; return $fonts; } );
This will stop GP from requesting it from Google.
I’m seeing the
@import
code twice in your source. Once in Simple CSS, which is correct. The other is outside of any CSS areas, which is why you’re seeing it on the site. Has it been added twice?June 19, 2019 at 3:08 am #934322Lisa
Tom HI
Re. the code showing on the front end… Yes by mistake I had it first in the GP hooks – now deleted.
With regard to the code that you gave me.I already have this in code snippets.
_____________________________________________________________
add_filter( ‘generate_typography_customize_list’, ‘tu_add_google_fonts’ );
function tu_add_google_fonts( $fonts ) {
$fonts[ ‘open_sans_hebrew’ ] = array(
‘name’ => ‘Open Sans Hebrew’,
‘variants’ => array( ‘400’, ‘500’, ‘700’ ),
‘category’ => ‘serif’
);return $fonts;
}
______________________________________________________is this wrong what I already have here?
HOw do I add the second font to this code?Lisa
June 19, 2019 at 5:11 am #934449Tom
Lead DeveloperLead DeveloperYes, that’s not the correct filter.
Instead, do this:
add_filter( 'generate_typography_default_fonts', function( $fonts ) { $fonts[] = 'Open Sans Hebrew'; $fonts[] = 'Second Font Name Here'; return $fonts; } );
That will add the fonts to the default/system fonts area in your dropdown (instead of Google fonts).
-
AuthorPosts
- You must be logged in to reply to this topic.