Skip to content

Conversation

@florian-lefebvre
Copy link
Member

@florian-lefebvre florian-lefebvre commented Apr 16, 2025

Changes

  • Improves the generated fallback name. It now takes names with quotes into account by removing the quotes to avoid creating invalid strings
  • Refactors font face declaration generation so the logic is shared
  • Improves the quality of fallbacks by pulling system metrics (RFC feedback):
    • I didn't notice that initially but to get better fallbacks, you need to provide the metrics of the target font file (done by reading the font file) as well as the metrics of the fallback font (system font eg. Arial)
    • So now, the metrics of system fonts used as fallbacks are put in a constant to avoid having to add the @capsizecss/metrics package (which is huge and was removed in fix(fonts): lighter fallbacks #13626)
  • Makes changes to implementation copied from nuxt/fonts and capsize to simplify things

Testing

Tests added

Docs

Changesets

@florian-lefebvre florian-lefebvre self-assigned this Apr 16, 2025
@changeset-bot
Copy link

changeset-bot bot commented Apr 16, 2025

🦋 Changeset detected

Latest commit: 16b1478

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Apr 16, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Apr 16, 2025

CodSpeed Performance Report

Merging #13632 will not alter performance

Comparing fix/fonts-fallback-name (16b1478) with main (99af0d1)

Summary

✅ 6 untouched benchmarks

@florian-lefebvre florian-lefebvre marked this pull request as ready for review April 16, 2025 10:19
Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I left nitpicks, but you can merge away :) One suggestion: let's put more description in the changeset, at least let's explain that these changes affect the experimental Fonts API.

Co-authored-by: Sarah Rainsberger <[email protected]>
@florian-lefebvre florian-lefebvre merged commit cb05cfb into main Apr 16, 2025
16 checks passed
@florian-lefebvre florian-lefebvre deleted the fix/fonts-fallback-name branch April 16, 2025 11:36
@astrobot-houston astrobot-houston mentioned this pull request Apr 16, 2025
openscript pushed a commit to openscript/astro that referenced this pull request Sep 12, 2025
* feat(fonts): fallback improvements

* feat: improve fallbacks generation

* chore: comments

* Update packages/astro/src/assets/fonts/utils.ts

Co-authored-by: Emanuele Stoppa <[email protected]>

* Apply suggestions from code review

Co-authored-by: Sarah Rainsberger <[email protected]>

---------

Co-authored-by: Emanuele Stoppa <[email protected]>
Co-authored-by: Sarah Rainsberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: astro Related to the core `astro` package (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants