Skip to content

Commit 9be54c7

Browse files
fix(fonts): less aggressive filtering (#14701)
1 parent be566b3 commit 9be54c7

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

.changeset/three-apples-roll.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'astro': patch
3+
---
4+
5+
Fixes a case where the experimental Fonts API would filter available font files too aggressively, which could prevent the download of woff files when using the google provider

packages/astro/src/assets/fonts/logic/normalize-remote-font-faces.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export function normalizeRemoteFontFaces({
1414
return (
1515
fonts
1616
// Avoid getting too much font files
17-
.filter((font) => (typeof font.meta?.priority === 'number' ? font.meta.priority === 0 : true))
17+
.filter((font) => (typeof font.meta?.priority === 'number' ? font.meta.priority <= 1 : true))
1818
// Collect URLs
1919
.map((font) => {
2020
// The index keeps track of encountered URLs. We can't use the index on font.src.map

packages/astro/test/units/assets/fonts/logic.test.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,16 +368,20 @@ describe('fonts logic', () => {
368368
src: [],
369369
meta: { priority: 0 },
370370
},
371-
// Will be ignored
372371
{
373372
src: [],
374373
meta: { priority: 1 },
375374
},
375+
// Will be ignored
376+
{
377+
src: [],
378+
meta: { priority: 2 },
379+
},
376380
],
377381
urlProxy,
378382
fontTypeExtractor: createFontTypeExtractor({ errorHandler: simpleErrorHandler }),
379383
}).length,
380-
4,
384+
5,
381385
);
382386
});
383387

0 commit comments

Comments
 (0)