Replies: 5 comments 3 replies
-
|
This sounds like a very reasonable improvement. Right now, when the fallback font only uses the regular local source, bold and italic text can temporarily render with incorrect styling while the custom font is loading, which affects readability and causes a noticeable visual shift. Automatically mapping fallback variants to their corresponding local bold/italic versions would definitely improve the loading experience, especially on slower connections. It would also make the transition to the final web font feel much smoother and more consistent. If automatic generation is difficult because of platform/font differences, then allowing manual fallback local source assignment through the API would still be a very useful solution and would give developers more control over typography behavior during font loading. |
Beta Was this translation helpful? Give feedback.
This comment was marked as off-topic.
This comment was marked as off-topic.
-
|
@jbasoo yeah I think it'd be good! If possible I'd prefer avoiding letting users specify there custom fallbacks. Currently, these are the fallbacks we have: https://github.com/withastro/astro/blob/b6ee23d339311c356ad25781f62454aee289e47b/packages/astro/src/assets/fonts/infra/system-fallbacks-provider.ts#L5-L55. Checking https://www.cssfontstack.com/ tho, it seems the only one where we could have more specific fallbacks is Arial, with Arial Black. Does that sound correct? |
Beta Was this translation helpful? Give feedback.
-
|
@florian-lefebvre Based on the font-face-name info from MDN and my testing, specifying the font's fullName e.g. "Arial Bold", "Arial Italic", "Arial Bold Italic" loads that specific local font. On my machine (Mac) and phone (Android) this works fine but I suspect that might not always be the case so we could still use regular Arial as a secondary fallback on the fallback |
Beta Was this translation helpful? Give feedback.
-
|
Tackled in withastro/astro#16908 |
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
Currently all fallback text is rendered as the normal font weight. The solution for this is to set the local src of the fallback font to the specific bold/italic variants.
Background & Motivation
I asked if it was possible to set the local src of font fallbacks in the Discord support channel and as it isn't @florian-lefebvre suggested it would be good to start a discussion here. The main benefit of this strategy is that the expected readability is retained on slow connections. If the font takes a while to download then at least the user still gets correctly formatted text, which also makes it a little less jarring when the custom font is swapped in.
Goals
Either automatically generate bold & italic fallbacks for bold & italic fonts, or extend the API to allow manual assignment of the fallback local src.
Beta Was this translation helpful? Give feedback.
All reactions