We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents e1c379a + 088eab5 commit a587220Copy full SHA for a587220
src/type/p5.Font.js
@@ -1481,7 +1481,15 @@ function font(p5, fn) {
1481
let isCSS = path.includes('@font-face');
1482
1483
if (!isCSS) {
1484
- const info = await fetch(path, { method: 'HEAD' });
+ let info;
1485
+ try {
1486
+ info = await fetch(path, { method: 'HEAD' });
1487
+ } catch (e) {
1488
+ // Sometimes files fail when requested with HEAD. Fallback to a
1489
+ // regular GET. It loads more data, but at least then it's cached
1490
+ // for the likely case when we have to fetch the whole thing.
1491
+ info = await fetch(path);
1492
+ }
1493
const isCSSFile = info.headers.get('content-type')?.startsWith('text/css');
1494
if (isCSSFile) {
1495
isCSS = true;
0 commit comments