-
tom_cg
Hi,
as mentioned here https://generatepress.com/forums/topic/add-local-font-to-generateblock-dropdown/ it was planned in 1.5.0 to add a filter for custom fonts. I still cannot see this in the changelog.
Was it implemented actually? If not, will it be?This would be a hardly needed feature as I can only access the system fonts there when Google fonts is deactivated. We must not use Google fonts due to law restrictions, so…
Thanks!
-
Hi there,
Yes, you can do this:
add_filter( 'generateblocks_typography_font_family_list', function( $fonts ) { $fonts[] = [ 'label' => 'My custom fonts', 'options' => [ [ 'label' => 'My cool font', 'value' => 'My cool font', ], [ 'label' => 'Another font', 'value' => 'Another font', ], ], ]; return $fonts; } );
Let me know if you need more info 🙂
-
tom_cg
That worked perfectly, thanks!
-
Hi,
I have several questions, 2 related to topic and one addditional1) where to add code (or as a snippet?),
2) what I need to change in code if i have only one font named “Breath”
3) additional: I don’t have “font manager” in customiser , what i need to change/update? -
Hi there,
1. its a PHP Snippet. See this doc for adding it:
https://docs.generatepress.com/article/adding-php/
2, For a single font:
add_filter( 'generateblocks_typography_font_family_list', function( $fonts ) { $fonts[] = [ 'label' => 'My custom fonts', 'options' => [ [ 'label' => 'Breath', 'value' => 'Breath', ], ], ]; return $fonts; } );
3. You would need to enable Dynamic Typography in Customizer > General:
https://docs.generatepress.com/article/switching-to-dynamic-typography/
-
Hi David, thanks a lot! worked it out!
-
Glad to hear that!
-
danstramer
Following up in this, as I’m on a project using local fonts –
I think it would be very beneficial that all the fonts added via the customizer (After adding the @font-face rules to the css stylsheet) would be automatically added to the GB typography dropdown.By the way, I do not have the option for dynamic typography as noted here – https://docs.generatepress.com/article/switching-to-dynamic-typography/
GP version 3.4.0Thanks
Dan -
Fernando
Hi Dan,
The filter shared by Tom is the way to add it.
Automatically, that’s not possible right now, and the code to apply that may be too bulky or bad performance-wise. You may request a feature for that though here: https://feedback.generateblocks.com/
-
danstramer
Thanks Fernando.
it’s working alright with the filter that Tom provided, I think it would make sense to add them anyway to the GB typography dropdown, since you added them in the customizer.
Regarding the dynamic typography selection not showing up – is that normal? -
Fernando
There’s a different filter for that which you need to add as well- GP font filter: https://generate.support/topic/removing-fonts-from-font-family-dropdown/#post-22123
-
danstramer
Thanks.
I think that GP + GB need to optimize the font UI process – not sure if it’s in the works…Dan
-
Fernando
For GP, you can request here: https://feedback.generatepress.com/
-
danstramer
Well it’s combined and connected:
The local fonts that are set up on the customizer should be available. Is the GB typography drop-down and populated there automatically. -
Hi there,
we been waiting on WordPress to finalise their font management function which has been pushed back a few times.
If thats up to the job we should be able to integrate both products into that function. Allowing user to manage local fonts in one place. -
danstramer
That would be great!
- You must be logged in to reply to this topic.