-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Using custom font causes usePDF instance to indefinitely remain as 'loading' #2675
Comments
It seems I'm encountering the same issue. |
I have the same problem also. |
Same problem! |
I'm also running into this issue. I am producing a PDF via the
When running this code, with a custom font, I see that chunks of stream content are getting loaded, but the "end" stream event is never called. It simply hangs on the last chunk and the promise is never resolved |
I have the same problem!! |
face same problem with next.js when using I am using diffrent fonts, but facing issue in only one font (Greycliff CF) , other all fonts are working. |
I have the same issue. When downloading an example google font from this list and importing that, it does work (for example with http://fonts.gstatic.com/s/roboto/v16/zN7GBFwfMP4uA6AR0HCoLQ.ttf)
However when I then open the same file in FontForge, and export it as "bad.ttf" without changing any of the settings, it suddenly Fails:
It also seems to fail on any other non google font in my experience. Can it be that it somewhere only accepts fonts that match the checksum of fonts available via google fonts? Is there any other unspecified encoding parameter that determines if it can handle the .ttf file? There really seems to be barely a difference in the files... I am lost |
Hi @Linkerbrain, I can confirm that using Google Fonts resolves my issue as well. Although this is a big annoyance on my side, since my project needs access to non-Google fonts. |
For me that is also the case, custom fonts is an essential part of my project so this is a really breaking issue. To debug, do you know when streaming the result with a google font, if the last chunks/end event include anything about the font? Maybe we could hotfix it by fake appending a standard end chunk after a set amount of time. |
@Linkerbrain I tried this with a So, it appears that the text literally cannot be rendered. |
same issue as well |
This is happening to me as well. |
The way we resolved this was by going back to using the system packaged fonts. We had to fully abandon the use of imported fonts for now. |
Not really an option for a lot of users that have to adhere to style guides... :( |
I was hit by this too. After some investigation, it seems to have been caused by the underlying restructure dependency updating from 3.0.0 to 3.0.1. |
Have you tried a downgrade with |
Yes, worked for me. |
Great, I spend hours yesterday to find the broken dependency without success. Thank you! |
@cduff Appreciate you posting this. Thank you, this fixed worked. By adding this to the Resolutions/Overrides. These issues have been fixed. NPM What was your process to be able to find this? Curious for future issues. Did you look into the lock file, look into fontkit and dependencies and go one by one to see recent upgrades? |
I do have the same issue. However, I noticed it's not the |
@PelosiTech I noticed it broke from one deployment to the next even though the version of |
Yes, that's correct. In my example I originally posted, commenting out the use of the custom font in the stylesheet fixes the issue. At the moment, overriding the restructure package back to 3.0.0 is the correct workaround, as others have noted above. |
I'm guessing a bug was introduced into restructure in 3.0.1. Just now I can't see any new issues listed in its repo related to this: https://github.com/foliojs/restructure/issues. I'm not familiar enough with the internal workings of |
Hi @diegomura, any updates on this issue? can we add a lock file to ensure this doesn't happen again? |
Two days fighting this very issue! |
oh gosh same problem with fonts const fileBlob = await pdf(<My Doc />).toBlob() using last version of library 3.4.2 |
Hi. I'm new to these tools, but I'm trying to create a repro so I can investigate what's happening in restructure. Can anyone give some pointers on how to get from a simple repro? What I'm trying currently:
|
I have a smaller repro see foliojs/fontkit#331 (comment) And (edit) have a fix PR in foliojs/restructure#62 edit the restructure PR was merged.. |
Thanks man, you made my day! Been debugging this issue for the past two nights! |
@Frontend-io I have a merged PR in the dep's dep that fixes it. Just waiting for @devongovett to make a new restructure release to patch. |
I have the same problem also. |
You saved my life |
I'm still waiting on restructure to publish a 3.0.2 with the actual fix. It's already merged. |
and install npm version of react-pdf Overriding restructure was needed because of this issue: diegomura/react-pdf#2675
and install npm version of react-pdf Overriding restructure was needed because of this issue: diegomura/react-pdf#2675
and install npm version of react-pdf Overriding restructure was needed because of this issue: diegomura/react-pdf#2675
and install npm version of react-pdf Overriding restructure was needed because of this issue: diegomura/react-pdf#2675
@PelosiTech thanks for the workaround! You could also update your comment for those using pnpm Overrides: {
"pnpm": {
"overrides": {
"restructure": "3.0.0"
}
}
} |
Devon released @NathZ1 if this also resolved for you, I guess the issue can be closed? |
…ig (#303) * chore(deps): update minors/patches * chore(deps): replace pretty-quick with lint-staged, update prettier * chore(eslint): fix eslint config * chore: update .gitignore to include developer notes * chore(deps): update swagger-ui-dist * chore(deps): update html-react-parser * chore(deps): remove local version of react-pdf and install npm version of react-pdf Overriding restructure was needed because of this issue: diegomura/react-pdf#2675 * chore(KUI-1166): add changed built components * chore(KUI-1162): update react to 18 * chore(deps) minor deps update * fix(KUI-1162): fix layout issues caused by footer (by making it position=absolute), also fix layout within footer * fix(KUI-1162): fix nested style issue by downgrading @react-pdf/layout via overrides. See issue: diegomura/react-pdf#2725 * fix(KUI-1166): downgrade react-pdf to latest version without memory issues --------- Co-authored-by: Benjamin Langlotz <[email protected]>
@muhammadkasimm hey, I'm glad you got it working for you. However, you might be encountering a different issue, as the issue here had to do with a bug I introduced (sorry!) but was fixed in more generally, should this issue be closed or fixed in react-pdf? |
Describe the bug
Registering a custom font with Font.register() results in usePDF never generating the PDF as expected. Commenting out the use of the custom font in StyleSheet allows PDF to generate, which leads me to believe it is an issue with how @react-pdf/renderer instantiates custom fonts. There is no error thrown, making it very difficult to diagnose the issue...
To Reproduce
This minimal example of index.tsx shows the reproducible error (React 18, Webpack 5 configuration, NOT Create React App):
Output of console.logs shows the path to the font and the font being registered, however the instance.loading remains = true indefinately. I have followed the path to the font and the path is correct
Expected behavior
PDF is available to download via instance.url
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: