Open dancrevier opened 1 year ago
π @dancrevier
π Thanks for opening this pull request! π
Please follow the contributing guidelines. And we use semantic commit messages to streamline the release process.
Examples of commit messages with semantic prefixes:
fix: don't overwrite prevent_default if default wasn't prevented
feat: add graph.scale() method
docs: graph.getShortestPath is now available
Things that will help get your PR across the finish line:
npm run lint
locally to catch formatting errors earlier.We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can.
Patch and project coverage have no change.
Comparison is base (
b751cbf
) 62.93% compared to head (38abea8
) 62.93%.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.
I ran this branch locally, and it fixed my issue reported here for the most part. Google fonts are loading now.
The part that's not fixed is the icons, but that appears to be a separate issue.
When can we get this PR reviewed and merged in? This bug is blocking us from adopting this package.
+1
+1
+1
+1! May we have this merged? Thank you so much!
+1! May we have this merged? Thank you so much!
pls merge
+1
+1 needs this issue fixed
We need this to be merged in.
+1 pls
Come on, we need this.
Why is this not merged yet?
there is a default fix for this first get the fonts fontEmbedCss
and then skipFonts
async function useHtml2Img(el: HTMLCanvasElement) {
try {
const fontEmbedCss = await getFontEmbedCSS(el);
const blob = <Blob>(
await toBlob(el, { skipFonts: true, fontEmbedCSS: fontEmbedCss })
);
if (window.saveAs) {
window.saveAs(blob, 'new.png');
} else {
saveAs(blob, 'new.png');
}
} catch (error) {
console.log('error: ', error);
}
}
Fixes the handling of font css when cssRules are inaccessible.
Description
When cssRules are inaccessible in a style sheet, getCSSRules will throw an exception trying to read them, and then the catch handler will fetch the css. But, when it goes to insert the rule, it has a bug where it uses sheet.cssRules.length, which causes an exception again and the rules are lost.
This results in the error:
This is referenced in a few issues such as issue #49.
Motivation and Context
This fixes issues when fonts are referenced via external style sheets and the css cannot be read. The resulting image will be missing the fonts that failed. This error is mentioned in a few issues such as https://github.com/bubkoo/html-to-image/issues/49.
Types of changes
Self Check before Merge