Skip to content

Add support for woff2 via an addon #7693

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 7, 2025
Merged
Changes from 1 commit
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
Prev Previous commit
Load the non-picked font so it can still be accessed via CSS
  • Loading branch information
davepagurek committed Apr 6, 2025
commit 59e11a06108b5cfcf42aeb95f2e11a09b5f00ee1
15 changes: 12 additions & 3 deletions src/type/p5.Font.js
Original file line number Diff line number Diff line change
Expand Up @@ -1022,7 +1022,7 @@ function font(p5, fn) {
name,
src,
fontDescriptors,
load: async () => {
loadWithData: async () => {
let fontData;
try {
const urlMatch = /url\(([^\)]+)\)/.exec(src);
Expand All @@ -1035,7 +1035,8 @@ function font(p5, fn) {
}
} catch (_e) {}
return create(this, name, src, fontDescriptors, fontData)
}
},
loadWithoutData: () => create(this, name, src, fontDescriptors)
});
}
}
Expand Down Expand Up @@ -1090,7 +1091,15 @@ function font(p5, fn) {
closestMatch = font;
}
}
return (closestMatch || possibleFonts.at(-1))?.load();
const picked = (closestMatch || possibleFonts.at(-1));
for (const font of possibleFonts) {
if (font !== picked) {
// Load without parsing data with Typr so that it still can be accessed
// via regular CSS by name
font.loadWithoutData();
}
}
return picked?.loadWithData();
}

let pfont;
Expand Down