Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .changeset/red-parrots-drum.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
'astro': patch
---

**BREAKING CHANGE to the experimental Fonts API only**

Updates the default `subsets` to `["latin"]`

Subsets have been a common source of confusion: they caused a lot of files to be downloaded by default. You now have to manually pick extra subsets.

Review your Astro config and update subsets if you need, for example if you need greek characters:

```diff
import { defineConfig, fontProviders } from "astro/config"

export default defineConfig({
experimental: {
fonts: [{
name: "Roboto",
cssVariable: "--font-roboto",
provider: fontProviders.google(),
+ subsets: ["latin", "greek"]
}]
}
})
```
2 changes: 1 addition & 1 deletion packages/astro/src/assets/fonts/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export const remoteFontFamilySchema = requiredFamilyAttributesSchema
*/
styles: z.array(styleSchema).nonempty().optional(),
/**
* @default `["cyrillic-ext", "cyrillic", "greek-ext", "greek", "vietnamese", "latin-ext", "latin"]`
* @default `["latin"]`
*
* An array of [font subsets](https://knaap.dev/posts/font-subsetting/):
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/assets/fonts/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const LOCAL_PROVIDER_NAME = 'local';
export const DEFAULTS: Defaults = {
weights: ['400'],
styles: ['normal', 'italic'],
subsets: ['cyrillic-ext', 'cyrillic', 'greek-ext', 'greek', 'vietnamese', 'latin-ext', 'latin'],
Copy link
Member

Choose a reason for hiding this comment

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

Oh, I’m seeing now we already didn’t include some important subsets. I think this makes sense then, as much as I dislike encoding this bias.

I’d say we should require setting subsets, but given not all providers support it, that would end up being pretty confusing I think.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah that's the problem IMO

subsets: ['latin'],
// Technically serif is the browser default but most websites these days use sans-serif
fallbacks: ['sans-serif'],
optimizedFallbacks: true,
Expand Down