Automattic / Automattic/custom-fonts

Handle themes where body-text weights are non-standard values

Open
#269 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
PHP
Stars
4
Forks
2
PR merge metrics
No merged PRs in 30d

Description

The [Atrium theme](https://wordpress.com/themes/atrium/) uses `500` for its bold font weight in order to leverage its use of the `300` weight for body text (both set in Roboto from Google Fonts).

When a `body-text` font family is set, we set the variations `['n4', 'i4', 'n7', 'i7']` by default, naïvely expecting the theme to pick them up properly. This naïvete is almost always fine in practice, but, for bold, will pick the `400` weight of the new font before scaling up to the bold at `700`.

But, if we want to be robust, we should have some way to say something like:

``` php
$jetpack_fonts->add_weight( 'body-text', 'regular', '/*selectors for regular weight go here */');
$jetpack_fonts->add_weight( 'body-text', 'bold', '/*selectors for bold go here */');
```

And then we can explicitly set those weights when rendering our font CSS. This would be optional, of course.

That being said, perhaps this is actually a problem in theme CSS: since behaviour like this will nearly always rely on the Google Font loading properly, perhaps the theme author should consider a more progressively enhanced approach, to only use the 300/500 weights if/when the font is loaded.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing how body-text font variations are selected and how font CSS is rendered, then compare the Atrium theme's 300/500 usage with the current default mapping. Done means an optional mechanism can associate regular and bold weights with selectors without breaking the existing defaults.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, wordpress
Domain
frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.