Closed famousprince closed 7 months ago
@famousprince I've never encountered this deploying to Vercel and I'm not able to reproduce the issue. There has been some discussion about the error in the React PDF repo but from the best I can gather the resume repo is set up the recommended way.
Do you have any changes to the repo, e.g. different fonts? Are the fonts I provided correctly loaded into /public/fonts
?
@famousprince It basically comes down to the fact that you need an absolute path to a font file, and the file has to be .ttf
. So either you're not pointing to a TTF or you're pointing to a file that doesn't exist.
If local files aren't working, you could try pointing to CDN files from Google, e.g.:
const albertSrc = 'https://fonts.gstatic.com/s/albertsans/v1';
const jetbrainsSrc = 'https://fonts.gstatic.com/s/jetbrainsmono/v18';
Font.register({
family: 'Albert Sans',
fonts: [
{
fontStyle: 'normal',
fontWeight: 400,
src: `${albertSrc}/i7dZIFdwYjGaAMFtZd_QA3xXSKZqhr-TenSHq5P_rI32TxAj1g.ttf`,
},
{
fontStyle: 'italic',
fontWeight: 400,
src: `${albertSrc}/i7dfIFdwYjGaAMFtZd_QA1Zeelmy79QJ1HOSY9AX74fybRUz1r5t.ttf`,
},
{
fontStyle: 'normal',
fontWeight: 700,
src: `${albertSrc}/i7dZIFdwYjGaAMFtZd_QA3xXSKZqhr-TenSHTJT_rI32TxAj1g.ttf`,
},
{
fontStyle: 'italic',
fontWeight: 700,
src: `${albertSrc}/i7dfIFdwYjGaAMFtZd_QA1Zeelmy79QJ1HOSY9Dw6IfybRUz1r5t.ttf`,
},
],
});
Font.register({
family: 'JetBrains Mono',
fonts: [
{
fontStyle: 'normal',
fontWeight: 500,
src: `${jetbrainsSrc}/tDbY2o-flEEny0FZhsfKu5WU4zr3E_BX0PnT8RD8yKxjPVmUsaaDhw.ttf`,
},
],
});
Thank you Colin! I updated the PDF.tsx
to https://github.com/colinhemphill/nextjs-resume/blob/0b583b8cf3f932e58e81479868ce40767c6f34b7/src/components/PDF/PDF.tsx then it works well.
@famousprince Awesome, I'll probably switch to using the CDN fonts as the default instead of local files.
Just forked and deployed on Vercel, not even set up the optional $PRIVATE_KEY environment variable.
Vercel Functions log told me this:
How do we solve this problem?