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
5 changes: 5 additions & 0 deletions .changeset/tired-worlds-dream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Fixes a case where invalid URLs would be generated in development when using font families with an oblique `style` and angles
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ export class DevFontFileIdGenerator implements FontFileIdGenerator {
return weight?.replace(/\s+/g, '-');
}

#formatStyle(style: unifont.FontFaceData['style']): string | undefined {
return style?.replace(/\s+/g, '-')
}

generate({
cssVariable,
originalUrl,
Expand All @@ -41,7 +45,7 @@ export class DevFontFileIdGenerator implements FontFileIdGenerator {
return [
cssVariable.slice(2),
this.#formatWeight(font.weight),
font.style,
this.#formatStyle(font.style),
font.meta?.subset,
`${this.#hasher.hashString(this.#contentResolver.resolve(originalUrl))}.${type}`,
]
Expand Down
9 changes: 9 additions & 0 deletions packages/astro/test/units/assets/fonts/infra.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,15 @@ describe('fonts infra', () => {
}),
'foo-200-700-italic-cyrillic-whatever.woff2',
);
assert.equal(
resolver.generate({
cssVariable: '--foo',
font: { weight: '500', style: 'oblique 0deg 15deg', meta: { subset: 'latin' }, src: [] },
originalUrl: 'whatever',
type: 'woff2',
}),
'foo-500-oblique-0deg-15deg-latin-whatever.woff2',
);
});

describe('UnifontFontResolver', () => {
Expand Down
Loading