Skip to content

feat(fonts): experimental release #12775

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 68 commits into from
Apr 14, 2025
Merged

feat(fonts): experimental release #12775

merged 68 commits into from
Apr 14, 2025

Conversation

florian-lefebvre
Copy link
Member

@florian-lefebvre florian-lefebvre commented Dec 18, 2024

API bash

Thanks for trying the experimental fonts API. Here's how to get set up.

Helpful resources

Setup

Create a project as normal, or use an existing one:

npm create astro@latest

Install the experimental astro release:

npm i https://pkg.pr.new/astro@12775

Configure fonts:

// astro.config.mjs
// @ts-check
import { defineConfig } from 'astro/config'

export default defineConfig({
    experimental: {
        fonts: {
            families: ['Roboto']
        }
    }
})

Usage

Use the Font component and the generated CSS variable:

---
import { Font } from 'astro:assets'
---

<Font family='Roboto' preload />

<style>
body {
    font-family: var(--astro-font-roboto);
}
</style>

What to test

  • Specifying some font options
  • Use another font provider
  • Use the local font provider
  • Test in dev and build

Changes

  • Adds first party support for fonts
  • For details, check all the PRs merged into this branch (linked in commit messages)

Testing

Manual and automated

Docs

Copy link

changeset-bot bot commented Dec 18, 2024

🦋 Changeset detected

Latest commit: 4ee7308

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 semver: minor Change triggers a `minor` release label Dec 18, 2024
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

This PR is blocked because it contains a minor changeset. A reviewer will merge this at the next release if approved.

@github-actions github-actions bot added pkg: astro Related to the core `astro` package (scope) docs pr labels Jan 21, 2025
Copy link

codspeed-hq bot commented Jan 21, 2025

CodSpeed Performance Report

Merging #12775 will not alter performance

Comparing feat/fonts (4ee7308) with main (762cc7f)

Summary

✅ 6 untouched benchmarks

* feat(fonts): work on local provider

* feat: config, types and options

* feat: dedupe

* feat: todo

* chore: clean

* feat: rework local provider

* feat: work on local provider

* fix: storage

* fix: types

* Discard changes to examples/basics/astro.config.mjs

* Discard changes to examples/basics/src/components/Welcome.astro

* Discard changes to examples/basics/src/layouts/Layout.astro

* chore: clean

* chore: comment

* feat: dedupe
* feat(fonts): improve providers

* feat: export defineFontProvider

* feat: type test

* feat: test providers

* feat: test providers utils

* feat: more tests

* fix: path
* feat(fonts): fallbacks

* feat: local

* fix: test

* feat: isGenericFontFamily test

* feat: generateFallbackCSS test

* feat: docs

* feat: simplify

* fix

* feat: improve schema

* Discard changes to examples/basics/astro.config.mjs

* feat: address reviews
* feat: improve loop

* feat: simplify cache

* feat: extract initialize logic

* fix: circular dependency

* fix: circular dependency

* feat: test

* chore: remove comment

* feat: address reviews

* chore: logs

* fix: normalize path

* test

* chore: remove logs
* feat(fonts): update local shape

* fix: types tests

* fix: tests
@florian-lefebvre florian-lefebvre added pr preview This PR has a preview release and removed pr preview This PR has a preview release labels Apr 4, 2025
* feat(fonts): improve local font files deletion

* feat: include path
* feat(fonts): update local shape

* fix: types tests

* fix: tests

* feat(fonts): update local provider to support entrypoints src and techs

* fix: tests

* chore: clean

* fix: default fallbacks

* fix: paths

* feat: extract variants transform to dedicated function
@florian-lefebvre florian-lefebvre added pr preview This PR has a preview release and removed pr preview This PR has a preview release labels Apr 4, 2025
@github-actions github-actions bot removed the pr preview This PR has a preview release label Apr 4, 2025
* fix(fonts): patch unifont

* fix: fontsource
* feat(fonts): remove default provider

* feat: tests

* Update index.ts
@ascorbic ascorbic added pr preview This PR has a preview release and removed pr preview This PR has a preview release labels Apr 8, 2025
Copy link
Member

@sarah11918 sarah11918 left a comment

Choose a reason for hiding this comment

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

Just adding a block for the changeset, which will wait until docs are finalized! 🙌

Co-authored-by: Sarah Rainsberger <[email protected]>
Co-authored-by: Armand Philippot <[email protected]>
@florian-lefebvre florian-lefebvre marked this pull request as ready for review April 14, 2025 09:02
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.

I already reviewed all the code in the previous PRs. I also did a rebase and resolved the conflicts. The project builds successfully!

Copy link
Member

@sarah11918 sarah11918 left a comment

Choose a reason for hiding this comment

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

Let's goooo! 🥳

@ematipico ematipico merged commit b1fe521 into main Apr 14, 2025
17 checks passed
@ematipico ematipico deleted the feat/fonts branch April 14, 2025 10:44
@astrobot-houston astrobot-houston mentioned this pull request Apr 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs pr pkg: astro Related to the core `astro` package (scope) semver: minor Change triggers a `minor` release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants