Skip to content
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

imported font crashes js after updating pdf-renderer to latest #2928

Open
hb27 opened this issue Nov 5, 2024 · 0 comments
Open

imported font crashes js after updating pdf-renderer to latest #2928

hb27 opened this issue Nov 5, 2024 · 0 comments

Comments

@hb27
Copy link

hb27 commented Nov 5, 2024

Hi,

This only happens on a server running production code. When the react project is launched using visual studio chrome launch option via debugger, it works as expected.

The error message in console was Uncaught TypeError: fb is on a constructor on the font.ttf file.
The font.ttf file in chrome debug window was export default _VITE_ASSET_DAXvI0Ge_

codesandbox of the error: https://codesandbox.io/p/devbox/ytrgy9

I have a npm react project built with vite.
I have a js file which uses the react-pdf/renderer with some fonts imported locally e.g.,

import customFont from './fonts/customFont.ttf'
Font.register({source: customFont})

This works with current setup.

package.json 
{
"@react-pdf/renderer: "^3.1.12",
"@react-pdf/font": "^2.3.6",
"@react-pdf/font":"^3.0.4",
"vite": "^5.2.13",
"react": "18.2",
}

On changing this to the following and running npm install, npm run build the javascript files crashed showing the error from the font .ttf file "acbd is not the constructor" etc

package.json 
{
"@react-pdf/renderer: "latest",
"@react-pdf/font": "latest",
"@react-pdf/font":"latest",
"vite": "^5.2.13",
"react": "18.2",
}

The same error happens if I run npm update @react-pdf/renderer the npm run build

@hb27 hb27 changed the title imported fond source crashes js after updating pdf-renderer to latest imported font crashes js after updating pdf-renderer to latest Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant