Site logo

Archived topic

Font weights

13 replies · Started by Jason on February 9, 2019

Viewing posts 1–14 of 14

Hello,

I am having some trouble with the font weights, hoping you can help. In this reply, you mentioned that all of the variants are loaded by default:

https://generatepress.com/forums/topic/generatepress-adds-all-the-google-font-weights/

However, I am not experiencing this. For example, I would like to use Poppins for my headings and google fonts shows it has variants 100-900. However in customizer, headings, I only have 300, regular, 500, 700 font weights to choose from.

I saw in some forum posts, you suggest altering the PHP to include custom fonts and variations. However, I don't think this is a good solution. If I were to hand this site off to a client they are going to expect the font weights to function like any other theme without coding in the functions.php or adding custom css.

Can you help me identify how to get all of the variations of all google fonts to load in the customizer? Thank you guys.

Hi Jason,

It's likely that we just need to update our built-in list to include those new variants.

For now, you will need to add a function to the site. However, this function adds the missing variants to the Customizer option - it doesn't make it necessary to add custom CSS or do anything different.

add_filter( 'generate_typography_customize_list', function( $fonts ) {
    $fonts['poppins']['variants'] = array( '100', '200', '300', '400' );
	
    return $fonts;
} );

You can adjust the list of variants to whatever you like.

Thank you for the reply.

While that may help in one instance, font trends are always changing....and so is the need to update fonts. I don't think adding a function or CSS on a per case basis is going to work.

Is there a way to update the database? Would you suggest I add a font plugin? Help lol

The only way to do what you're wanting is to have a direct link to the Google Fonts API which updates fonts and variants automatically. Technically, I believe it's possible. However, it can introduce a lot of issues as well. It's something I'd like to get figured out.

I'm not sure what you mean about updating the database?

I was referencing:

"It’s likely that we just need to update our built-in list to include those new variants."

I am not certain what's involved to update your list/data but if you could do that I would appreciate it. I am running into this issue all over the place. Just created a subheading and font weight missing for that font also!

I'll see if we can get that updated in the next GP Premium update :)

Thanks!

I used the filter above and it worked. However when I tried to do the same for josefin sans font, it didn't work.

Can you tell me. Is this correct?

add_filter( 'generate_typography_customize_list', function( $fonts ) {
$fonts['josefin sans']['variants'] = array( '100', '200', '300', '400' );

return $fonts;
} );

Looks like you're just missing the underscore in the name:

add_filter( 'generate_typography_customize_list', function( $fonts ) {
    $fonts['josefin_sans']['variants'] = array( '100', '200', '300', '400' );

    return $fonts;
} );

Let me know :)

Worked perfectly thanks

You're welcome :)

Hi Tom,

I'm having the same issue. As of GPP v2.1.1 there is presumably an easier way for adding a font-weight of say 600 to the Font Manager, correct?

Background: I have added Google-fond "Quicksand" to the Font Manager. Whether I select H2 font-weight "bold" or "600" does not make any difference ;-(

I sense that something else is needed in order to get font-weight 600 to take effect. (See screenshot).

Any advice is much appreciated.

Thanks,
Jan

Hi Jan,

Have you assigned the font to H2? https://www.screencast.com/t/kzBhA4xLeZF

And Have you defined the typography in the page editor for this specific H2?

Any chance you can open a new topic and link us to the page?

Hi Ying,

Thanks for sharing the screenshot. I forgot to define the typography for H2.

It works fine now.

Best,
Jan

You are welcome :)

This archived topic is closed to new replies.