html-to-image icon indicating copy to clipboard operation
html-to-image copied to clipboard

export image very slowly when use custom fonts

Open klower opened this issue 1 year ago • 4 comments

I have defined some custom fonts: @font-face { font-family: 'SourceHanSansCN-Medium'; src: url(../../assets/fonts/SourceHanSansSC-Medium.otf); }

@font-face { font-family: 'SourceHanSansCN-Bold'; src: url(../../assets/fonts/SourceHanSansSC-Bold.otf); }

@font-face { font-family: 'SourceHanSansSC-Normal'; src: url(../../assets/fonts/SourceHanSansSC-Normal.otf); }

import { toJpeg, toPng } from 'html-to-image'; toJpeg(element, { // skipFonts: true, useCORS: true, preferredFontFormat:'embedded-opentype', allowTaint: true, height: element.scrollHeight, // width: element.scrollWidth, scale: 1, backgroundColor: '#ffffff', pageBreak: { mode: 'avoid-all' } }) It will take more then 20s to export jpeg... if I set 'skipFonts: true', It will take 3s to export jpeg...

so how should I do to apply custom fonts?

klower avatar Jan 11 '24 02:01 klower

👋 @klower

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.

biiibooo[bot] avatar Jan 11 '24 02:01 biiibooo[bot]

same issue,no idea to resolve it

Raven2049 avatar Jan 15 '24 02:01 Raven2049

any luck figuring that out?

gabrielxq avatar Jul 31 '24 19:07 gabrielxq