-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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
Achieve consistent font rendering between different platforms. #661
Comments
Did you try adding |
@nojvek platform plays a huge role in text handling, doing both rendering and font resolution. It is hard to get a pixel-perfect runs on both mac and linux. I'd rather recommend using per-platform test expectations. |
We have tried to render fonts in osx style on ubuntu with infinality. For the os it works, but it looks like puppeteer is somehow immune to it, which means: If i start chromium on ubuntu, it renders all the fonts according to infinality's configuration, but if i open the same page with puppeteer and create a screenshot, it is rendering fonts as usual. Any ideas @aslushnikov (addressing you directly since this issue is already closed)? It would be amazing to have fonts matching across platforms. |
@delijah the only difference between puppeteer-launched chrome and manual-launched chrome is a set of runtime flags. Pptr passes in quite a few to make chrome behave better for automation: I don't know much about infinality, but I'd start investigation from here. Hope this helps! |
I can confirm that adding |
Any updates to this issue? I'm also testing against boxes like CentOS and they have a different font as a default. It looks like in order to have consistent font rendering that we have to declare @font even for default fonts. |
We worked around font rendering by loading the same docker image in both
Mac and Linux.
I’m glad someone invented docker. Loading a consistent universe everywhere
is super useful.
|
@nojvek We did the same! I'm curious, did you still run into any small rendering differences with images after you switched to using Docker? We got rid of all of our font rendering inconsistencies, but are still sometimes noticing small, intermittent differences with images. |
Yeah, with the Docker image being loaded both in CI and our local environments, we get full consistency, barring this problematic, intermittent image-rendering issue. Seems to be something associated with |
@nojvek @theblang @booleanbetrayal Running into the same issue - could you please give a hint on how to run Chromium inside docker? |
@DenisGorbachev this might help: Running Puppeteer In Docker |
Adding infinality helped us make puppeteer fonts in docker closer to how they look when run on mac https://github.com/Kiwup/docker-node-infinality |
@nojvek, for a proper letter-spacing try '--font-render-hinting=none' or '--font-render-hinting=medium' |
Why was this issue closed? I'm unable to find a solution for this problem. Using docker is just a workaround, not a solution. |
@pladaria font rendering is fundamentally driven by the underlying OS - it falls outside of both Puppeteer and Chromium projects.
If anything, "consistent font rendering" is a feature request towards OS Vendors; we can't do much about it on the puppeteer side. |
Thank you for @HydraOrc helpful suggestion.
|
Fix font kerning for headless Chromium in Linux. Tested with Chromium in docker container on macOS. See screenshots attached to PR. See also puppeteer/puppeteer#661 puppeteer/puppeteer#2410 https://stackoverflow.com/questions/52552573/kerning-issues-with-headless-chrome
I had a similar issue, where screenshots with headless were different than headless=false. Disabling the GPU by passing |
@maartenbreddels Sadly though, that won't work if, for example, you have screenshot tests running in CI on a Linux box, but your developer box is non-Linux. |
I just noticed indeed, but even on the same machine it may give different results with/without headless/gpu, I thought it would be good to share that. |
Is there any solution now? |
@blinkcat the solution I ended up with (was also suggested here) was to always run my puppeteer (snapshot testing scripts) inside a docker image and mount the output folder to the host OS. that way puppeteer screenshots/pdfs are always generated in a consistent environment (docker image) but I have them in the host os (for example If I need to version control them) |
You're a legend (I realize you posted this two years ago) |
When using font render hinting on Chrome headless on Linux, the kerning is inconsistent. Several issues cover this, including: * puppeteer/puppeteer#661 * nzzdev/Q-server#193 Disabling that render hinting entirely results in correct kerning.
I spent a lot of time trying to get consistent font rendering, since unfortunately this is still an issue. But in the end I ended up with a completely different approach. I simply created a custom-triggered ci pipeline that will generate/update snapshots and push it back to the selected branch So in the local dev env, we dont have to ever update snapshots. We just run that pipeline and thus can get pixel perfect snapshots tests. No custom args and workarounds or anything. And with our setup its actually even easier to use this way. |
@josias-r did you find a way to only run the snapshots tests against changed stories?
|
@komplexb No the update-snapshots pipeline simply runs all "snapshotable" tests with the "--update-snapshots" argument. I don't think there is a reliable solution to only run tests for "updated code". There are possibilities with git diff to find changed files, but since files can import eachother, it is not certain whether another file change might have an impact on another file which did not change.
|
When using font render hinting on Chrome headless on Linux, the kerning is inconsistent. Several issues cover this, including: * puppeteer/puppeteer#661 * nzzdev/Q-server#193 Disabling that render hinting entirely results in correct kerning.
It seems I get pixel perfect rendering on multiple runs in my mac. However running tests on an ubuntu bux doesn't give me the same render. The difference is between font rendering usually. Pictures and boxes render just fine.
It would be great if I could turn on pure CPU rendering even for fonts in puppeteer so I can do render diffs and test for UI perceived changes due to css.
The text was updated successfully, but these errors were encountered: