themes icon indicating copy to clipboard operation
themes copied to clipboard

Add one more font to customizer with a blockbase child theme

Open base-creme opened this issue 4 years ago • 7 comments

Hi !

I want to add one more font to customizer with my blockbase child theme Test with Lato (Google font)

Test directly in the parent theme (blockbase)

I saw the font list in folder inc/customizer/wp-customize-fonts.php I tested the following code in the parent theme (blockbase) :

'lato' => array( 'fontFamily' => '"Lato", serif', 'slug' => 'lato', 'name' => 'Lato', 'google' => 'family=Lato:ital,wght@0,100;0,300;0,400;0,700;0,900;1,100;1,300;1,400;1,700;1,900', ),

And it works like a charm.

And in the child theme

Now I want to replicate this in my child theme to not affect the parent theme but I can't override that file.

Someone to help me achieving this ? :)

base-creme avatar Dec 23 '21 16:12 base-creme

I would like this too. At first I was thinking we should add a filter so that we can hook into the font list, but actually it would be way better if the font customizer just read the fonts out of the theme.json file. There is already support for specifying a header and body font as well as additional font families for the theme. So we just need the font customizer to use the values from there if there are any or otherwise use the hard-coded $fonts list.

timnicholson avatar Jan 24 '22 21:01 timnicholson

Anything new here for that issue ? :) It would be great to have a way to add or override the wp-customize-fonts.php of the blockbase theme in a child theme. Thanks !

base-creme avatar Feb 14 '22 10:02 base-creme

I'm interested to know how Gutenberg intends to offer this kind of functionality. Ideally Blockbase would offer that functionality in the same way to polyfill the expected functionality. "Filling the gaps of what will eventually be" has been one of Blockbase's primary purposes, more so than as a convenient parent theme.

pbking avatar Feb 14 '22 13:02 pbking

Looks like it's going this way: https://github.com/WordPress/gutenberg/pull/37140

MaggieCabrera avatar Feb 14 '22 13:02 MaggieCabrera

I think at some point we had logic to insert a font family that is not loaded by the parent, does this not work for you on your child theme's json file (under settings/typography/fontFamilies)?

{
	"fontFamily": "\"Poppins\", sans-serif",
	"fontSlug": "poppins",
	"slug": "body-font",
	"name": "Body (Poppins)",
	"google": "family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900"
},

MaggieCabrera avatar Feb 14 '22 13:02 MaggieCabrera

Hello @MaggieCabrera !

I can't access to the theme.json file anymore because I'm not the owner of the hosting for the site (it's live). I tried via the back-office in the "edit theme files" section but the theme.json file is not displayed. I keep in mind your return and will test it asap :)

Best.

base-creme avatar Mar 18 '22 11:03 base-creme

Retested and fonts can be added "the blockbase way" as Maggie pointed out above or "the gutenberg way" based on the webfonts API that was linked to. Both are achievable via a child's theme.json.

Closing this item. I don't believe we intend to add additional fonts to Blockbase at this time.

pbking avatar Mar 18 '22 14:03 pbking