-
-
Notifications
You must be signed in to change notification settings - Fork 696
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
PDF conversion is slow when CJK font is used #2120
Comments
Hi! This extra time is used to remove the unused characters from the font. As Noto CJK is huge (~20MB on my computer) and includes a lot of characters, it can take a lot of time.
Most of the time is spent in fonttools, and its subsetter has already been reported to be "slow" in fonttools/fonttools#2147. As proposed in that issue, we could try to use hb-subset instead. |
If I switch to an older release (52.2) conversion is much faster. 0.8 sec (version 52.2) vs 2.9 sec (version 61.2). |
That’s because font subsetting was done by Cairo, that we don’t use anymore. We’d probably get equivalent performance by using hb-subset. |
We’ve open a highly experimental branch that uses Harfbuzz to subset fonts, and that you can try: |
@martijnbrinkers I’ve open a draft pull request, if you want to test it. As the code is quite small and includes a fallback using the old way, we may consider merging this pull request. We still have to check where harfbuzz-subset is installed (probably Windows, maybe macOS, only some Linux distributions) and update the related documentation. |
If a CJK font is used, PDF conversion is slow.
Steps to reproduce (on AlmaLinux 9 but other Linux systems with a similar same font can be used as well)
Install font
install weasyprint
create html with Chinese characters
convert html to pdf with font installed
now remove font
convert html to pdf without font installed
For a simple html it takes about 6 times longer to convert to a PDF if a CJK font is used.
Is there a way to improve this?
The text was updated successfully, but these errors were encountered: