-
Notifications
You must be signed in to change notification settings - Fork 223
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
Requiring a variable font causes a type error #162
Comments
Having the same issue, has anyone found a fix? |
Same issue here, still no fix? |
Same issue, Next.js v13.0.3. |
Any update on this? Facing a similar issue. |
Same issue here using |
did you try removing |
Btw if you use variable .woff, the message disappears, but the font is not getting applied |
+1 hitting this with the same font
|
The workaround is to use a non variable version of the same font, which was fine for my use case (I only needed one weight) :) |
I'm facing this issue when using a |
I'm facing the same issue, any updates on this? |
Any update? |
+1 would like support for variable fonts |
I lost so much time trying to debug this. The error via
Switching to a non-variable font works, thank you. |
If working with google fonts to get non-variable weight ones I found that you have to spoof the user agent to something old get it to return non-variable weight ttf files: async function getTtfFont(family: string, axes: string[], value: number[]): Promise<ArrayBuffer> {
const familyParam = axes.join(',') + '@' + value.join(',');
// Get css style sheet with user agent Mozilla/5.0 Firefox/1.0 to ensure non-variable TTF is returned
const cssCall = await fetch(`https://fonts.googleapis.com/css2?family=${family}:${familyParam}&display=swap`, {
headers: {
'User-Agent': 'Mozilla/5.0 Firefox/1.0',
},
});
const css = await cssCall.text();
const ttfUrl = css.match(/url\(([^)]+)\)/)?.[1];
return await fetch(ttfUrl).then(res => res.arrayBuffer());
} |
Bug report
When satori's .addFonts method is called, it calls opentype which (in a Next.js app) throws the following error
Description / Observed Behavior
Could not load a variable font
Expected Behavior
The font loads
Reproduction
https://www.fontshare.com/fonts/general-sans
Additional Context
Originally was going to report this issue in shuding/opentype.js, but the repo has issues disabled, so was not sure if it was more appropriate to go in https://github.com/opentypejs/opentype.js or here
The text was updated successfully, but these errors were encountered: