PDFs: Switch to DomPDF & use Noto Sans (plus KR, SC, and Arabic) for Invoices & Docs.#1552
PDFs: Switch to DomPDF & use Noto Sans (plus KR, SC, and Arabic) for Invoices & Docs.#1552dd32 wants to merge 20 commits intoproductionfrom
Conversation
|
Noting that there's also |
| <meta charset="UTF-8"> | ||
| <link href="http://fonts.googleapis.com/css?family=Open+Sans:300,600,700" rel="stylesheet" type="text/css" /> | ||
| <?php // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedStylesheet -- This is rendered by wkhtmltopdf, so additional libraries are included directly. ?> | ||
| <link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@300..700&family=Noto+Sans+KR:wght@300..700&family=Noto+Sans+SC:wght@300..700" rel="stylesheet" type="text/css" /> |
There was a problem hiding this comment.
Thanks for your PR to resolve my issue!
How about swap font resolve order?
/* Current... */
font-family: 'Noto Sans KR', 'Noto Sans SC', 'Open Sans', sans-serif;
/* to this */
font-family: 'Noto Sans SC', 'Noto Sans KR', 'Open Sans', sans-serif;KR might use the same glyph points as of Chinese.
Note: I cannot reproduce same character missing(we call it "TOFU").
|
It looks like this isn't loading Open Sans at all now, because the Notos have latin characters, so it never falls back to Open Sans. I'd recommend updating the font stack to … Actually, that won't work either. I don't think wkhtmltopdf supports multiple fonts. If you do that, everything is "tofu". The tofu in Simplified Chinese goes away if you put Noto Sans SC first, but then Korean breaks. So it appears to only load the first font.
Maybe switching to something like dompdf would fix that, they have addressed CJK font support in this issue. |
|
I've tried on my local machine, but because of network error, wkhtmltopdf failed to download google fonts. I also tried another approach — installing
The complete diff of docker file is below: before__Dockerfile.php-fpm | Dockerfile.php-fpm – 2 Additions.pdf |
I thought that might be the case...
This too, except that as far as I could tell it definitely does because KR doesn't work without the KR font, and Chinese didn't work without the SC font, but with both they did load...
I did consider that, but I was hopeful that a quick font-change here would suffice :)
@fumikito Unfortunately we don't use the included Dockerfile in production, so it's a little more involved than just the change here :( |
|
🤷 I guess I was very wrong, or improperly tested :) Let's try |
|
After the subsetting work, I'm pretty familiar with these fonts 😅 |
|
Took forever to figure out why this wasn't working with invoices.. Turns out that if an embedded image is 404 / broken, then DomPdf seems to enter an endless forever loop. It seems to be that the broken-image fallback is well broken. Additionally; Before merging some performance profiling should be done to figure out if this is going to be too slow.. For invoices, I suspect the better solution will be to remove invoice generation from during the checkout, and moving it to be able to be downloaded from the Successful purchase landing page (ala #1555) |







Fixes #1433
It seems that the only thing missing on Invoices to make non-western characters work is that a) The system doesn't have any chinese/korean/japanese fonts installed and b) isn't specifying a webfont that supports these laguages.
Screenshots
Attempting to render #1433 (comment)
The Simplified Chinese still has a few missing characters, but much better than before. I'm not sure why these are missing, as the font appears to support those unicode characters.. It may be something in how I'm testing it.