Skip to content
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

feat(fonts): experimental release #12775

Draft
wants to merge 43 commits into
base: main
Choose a base branch
from
Draft

feat(fonts): experimental release #12775

wants to merge 43 commits into from

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: 3fcdba0

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 (100cd48) with main (70c9595)

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
florian-lefebvre and others added 14 commits March 5, 2025 15:30
* feat(fonts): css vars

* feat: tests and fix

* chore: add todos
* feat(fonts): as prop

* chore: comment
* feat(fonts): resolve config todos

* feat: work on schemas

* fix: local provider

* feat: local provider test

* feat: schemas tests

* feat: config tests

* feat: load test

* fix: types tests

* feat: address reviews
* feat(fonts): use capsize instead of fontaine

* fix: tests

* feat: extract regex to constant
* feat(fonts): add errors

* feat: component errors

* fix: error

* fix: tests

* Update packages/astro/src/core/errors/errors-data.ts

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

* Apply suggestions from code review

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

* feat: address reviews

* Update packages/astro/src/core/errors/errors-data.ts

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

* feat: improve errors

---------

Co-authored-by: Sarah Rainsberger <[email protected]>
* feat(fonts): typegen for <Font /> family prop

* feat: add internal jsdoc
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.

Reviewed the error messages as I'm not sure there's anything else in here for me right now.

(The changeset will be the last thing, when we're ready to H.Y.P.E.!)

@florian-lefebvre florian-lefebvre added the pr preview This PR has a preview release label Mar 25, 2025
Copy link

pkg-pr-new bot commented Mar 25, 2025

astro

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

@astrojs/cloudflare

npm i https://pkg.pr.new/@astrojs/cloudflare@12775

@astrojs/netlify

npm i https://pkg.pr.new/@astrojs/netlify@12775

@astrojs/node

npm i https://pkg.pr.new/@astrojs/node@12775

@astrojs/vercel

npm i https://pkg.pr.new/@astrojs/vercel@12775

commit: dc24bdd

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.

Thanks for pointing these errors out! Left some thoughts for you! 🙌

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) pr preview This PR has a preview release semver: minor Change triggers a `minor` release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants