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.
1 parent 60ef55e commit f535b05Copy full SHA for f535b05
src/type/p5.Font.js
@@ -1480,7 +1480,15 @@ function font(p5, fn) {
1480
let isCSS = path.includes('@font-face');
1481
1482
if (!isCSS) {
1483
- const info = await fetch(path, { method: 'HEAD' });
+ let info;
1484
+ try {
1485
+ info = await fetch(path, { method: 'HEAD' });
1486
+ } catch (e) {
1487
+ // Sometimes files fail when requested with HEAD. Fallback to a
1488
+ // regular GET. It loads more data, but at least then it's cached
1489
+ // for the likely case when we have to fetch the whole thing.
1490
+ info = await fetch(path);
1491
+ }
1492
const isCSSFile = info.headers.get('content-type')?.startsWith('text/css');
1493
if (isCSSFile) {
1494
isCSS = true;
0 commit comments