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

export image very slowly when use custom fonts #448

Open
klower opened this issue Jan 11, 2024 · 2 comments
Open

export image very slowly when use custom fonts #448

klower opened this issue Jan 11, 2024 · 2 comments
Labels

Comments

@klower
Copy link

klower commented Jan 11, 2024

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 klower added the bug label Jan 11, 2024
@vivcat
Copy link
Contributor

vivcat bot commented Jan 11, 2024

👋 @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.

@Raven2049
Copy link

same issue,no idea to resolve it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants