• I noticed that Create Block Theme can be used to add new fonts to the twentytwentythree theme.

    I suspect this is a bad idea, and updates to the theme would clobber the new fonts, so a child theme would be required.

    Is that correct, or is it actually ok to add fonts directly to twentytwentythree?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi @ryandjohnson I can replicate this, I added a Google Font and l used the rollback plugin to add a previous version of the theme, and the Google font was removed. I am not sure if this is the expected behavior for the plugin, I would suggest reporting this on GitHub for the developers to take a look:

    https://github.com/WordPress/create-block-theme

    Let me know if you need assistance with this

    Thread Starter ryandjohnson

    (@ryandjohnson)

    Based on this thread, I believe this is expected behavior, I was just looking for confirmation. As with other deep theme customization, a child theme is necessary to allow updates to the parent theme.

    That’s not a surprise, since it does appear that this plugin directly modifies the theme rather than having it’s own separate config that it’s applying dynamically.

    I was just looking for confirmation, since I was surprised to find that it would let me add fonts directly to twentytwentythree at all — since that is clearly inadvisable and is just going to lead to tons of support threads like the one I linked and now this new, similar one.

    Unfortunately, I am having trouble getting this plugin to work with child themes, as it correctly puts the font files in the child theme but the generated CSS path for the font still refers to the parent theme path for some reason. Not sure if it’s a problem with this plugin, twentytwentythree, or wordpress itself.

    Plugin Author Matias Benedetto

    (@mmaattiiaass)

    I was just looking for confirmation, since I was surprised to find that it would let me add fonts directly to twentytwentythree at all — since that is clearly inadvisable

    Hi @ryandjohnson this plugin is a tool intended to be useful to theme creators. Because of that, it allows you to create and modify themes.

    It is not inadvisable if you are creating a new theme based on twentytwentythree. There’s nothing wrong with that.

    But if you want to continue receiving twentytwentythree updates, for example, you can use tt3 as a parent theme. My comment on the thread you linked describes that.

    Right now I don’t know why the font families are not loading ok in your child theme. We would need to debug that.

    Thread Starter ryandjohnson

    (@ryandjohnson)

    I’m under a bit of a deadline, so I’m afraid I can’t provide much info at the moment. I ended up just reinstalling TT3 and then editing my child theme manually.

    I should have saved a copy of the old theme.json and diff’d them, but I’m afraid I did not. I added a list under settings/typography/fontFamlies with the custom fonts I needed and the CSS is being generated to the child theme’s path as expected, based on src like file:./assets/fonts/Montserrat-VariableFont_wght.woff2.

    One thing I noticed is that the way the child/parent theme.json are merged, the settings/typography/fontFamilies list from the child completely replaces the one in the parent. So the font families from TT3 no longer appear in the block editor. The theme.json v2 “living reference” doesn’t have any details about how child theme.json entries are merged with the parent’s, so no idea if this is by design or a bug.

    In any case, that’s ok for my scenario. I just duped the “system font” entry from TT3 so it would still be available in addition to the google fonts I added, i.e.

    child/theme.json:settings/typography/fontFamilies:
    ...
    
    {
            "fontFamily": "-apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,Oxygen-Sans,Ubuntu,Cantarell,\"Helvetica Neue\",sans-serif",
            "name": "System Font",
            "slug": "system-font"
    }
    
    ...

    A word of caution to anyone editing the theme.json file by hand, it does not use JSON5 conventions and is very strict on the input, so if you have an additional trailing comma, for example, your theme won’t load and you will just get a not-very-helpful “PHP Notice: Error when decoding a JSON file” message in your WP_DEBUG log.

    • This reply was modified 1 year, 9 months ago by ryandjohnson.
    • This reply was modified 1 year, 9 months ago by ryandjohnson.
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Ok to add fonts directly to twentytwentythree?’ is closed to new replies.