Closed chanzer0 closed 1 year ago
š @chanzer0
Thanks for opening your first issue here! If you're reporting a š bug, please make sure you include steps to reproduce it. To help make it easier for us to investigate your issue, please follow the contributing guidelines.
We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.
We had to append the desired fonts / CSS to the target node.
const targetNode = document.getElementById(targetId);
const styleElement = document.createElement('style');
styleElement.textContent = `
@font-face {
# ...
}
# Other required styles.
`;
targetNode.appendChild(styleElement);
// Use library to convert targetNode to an image type.
// ...
@zackbiernat's suggested implementation above is how we resolved this issue
This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.
Description
When using the library locally, calling![LT30-Index_2022_10_29-2022_11_29 (17)](https://user-images.githubusercontent.com/25206712/204642050-f882e60a-4a8a-44c5-b8fc-2795ca82bc80.jpeg)
.toJpeg()
works as intended, providing the following image:However, in production, with the same codebase, the following image with incorrect fonts is generated (even though the fonts render just fine on the actual page):![LT30-Index_2022_10_29-2022_11_29 (21)](https://user-images.githubusercontent.com/25206712/204642114-be51dd60-7653-4f01-a71d-4accaabc6438.jpeg)
Update I believe the issue lies somewhere in how the package is handling network requests. Locally, we can see that successful requests are made to the fonts:![image](https://user-images.githubusercontent.com/25206712/204847016-613b78c0-c8b8-4063-a426-94a0fa8deb28.png)
However, in production, these requests are not made:![image](https://user-images.githubusercontent.com/25206712/204847118-b5412acb-b121-4ef0-b2a2-95b49f31fb6d.png)
I'm not sure why, but therein lies the issue.
Update 2 What's even weirder is I'm
console.log
ing the response from.toJpeg()
as follows:And when I plug this base-64 string into an online image viewer/decoder, the output is correct (Even though the downloaded image is incorrect:
Expected Behavior
Fonts loaded in page should be styled and applied properly to the generated element.
Current Behavior
Font loaded and present in the page are not applied properly to the generated element
Steps To Reproduce
A live example of this can be found at this url by clicking on the "download image" icon present in the graph.
globals.css
component.tsx
Your Environment