Skip to content

Font subset configuration cannot be distinguished in font data array #16951

@ericswpark

Description

@ericswpark

Astro Info

Astro                    v6.3.8
Node                     v26.2.0
System                   Windows (x64)
Package Manager          bun
Output                   static
Adapter                  none
Integrations             @astrojs/mdx

If this issue only occurs in one browser, which browser is a problem?

N/A

Describe the Bug

When including multiple font subsets (such as ["latin", "korean"]) I need to be able to filter based on the subset type so that I can choose the correct subset based on locale. However, Astro currently bundles everything into one font data array with no subset field:

console.log(JSON.stringify(fontData["--font-nanum-gothic"]));
[{
  weight: '400',
  style: 'normal',
  src: [
    { url: '/_astro/fonts/0fc824ca67a3c0b8.woff2', format: 'woff2' },
    { url: '/_astro/fonts/72ec1fb94c7d67e0.woff', format: 'woff' }
  ]
}
{
  weight: '700',
  style: 'normal',
  src: [
    { url: '/_astro/fonts/38dce70dc92db240.woff2', format: 'woff2' },
    { url: '/_astro/fonts/0d2cf215f045e62f.woff', format: 'woff' }
  ]
}
{
  weight: '800',
  style: 'normal',
  src: [
    { url: '/_astro/fonts/37d8d241ec0d0519.woff2', format: 'woff2' },
    { url: '/_astro/fonts/eac1450f9dbc66fd.woff', format: 'woff' }
  ]
}
{
  weight: '400',
  style: 'normal',
  src: [
    { url: '/_astro/fonts/03ff47ed11e6637f.woff2', format: 'woff2' },
    { url: '/_astro/fonts/979e99dee51ad8f8.woff', format: 'woff' }
  ]
}
{
  weight: '700',
  style: 'normal',
  src: [
    { url: '/_astro/fonts/6b125e76b997a6f0.woff2', format: 'woff2' },
    { url: '/_astro/fonts/5c3551a89cb79353.woff', format: 'woff' }
  ]
}
{
  weight: '800',
  style: 'normal',
  src: [
    { url: '/_astro/fonts/e186fbca28a2cd4c.woff2', format: 'woff2' },
    { url: '/_astro/fonts/8c7a0558496c978c.woff', format: 'woff' }
  ]
}]

What's the expected result?

The font data array element should probably include a subset field if the relevant font.subsets option is defined, like this:

[
  {
    weight: '800',
    subset: 'korean',
    style: 'normal',
    src: [
      { url: '/_astro/fonts/e186fbca28a2cd4c.woff2', format: 'woff2' },
      { url: '/_astro/fonts/8c7a0558496c978c.woff', format: 'woff' }
    ]
  }
]

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-dcgw2fc4?file=src%2Fpages%2Findex.astro

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Labels

- P2: nice to haveNot breaking anything but nice to have (priority)fix verifiedReporter confirmed the triage bot fix workspkg: astroRelated to the core `astro` package (scope)

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions