11

Been running a screenshot pipeline for visual regression testing and hit something annoying — the same page renders slightly differently depending on the host OS. CentOS 7 vs Ubuntu 22.04 vs Alpine in Docker all produce different pixel outputs for identical URLs with identical Chrome versions.

The culprit is mostly font rendering. FreeType versions differ, fontconfig has different defaults, and some distros ship with subpixel antialiasing enabled while others don't. The result is text that's a pixel or two off, which is enough to trigger visual diff alerts on every single run.

Things I've tried:

  • Pinning the Chrome version — helps with browser-level rendering but doesn't fix OS-level font differences
  • Using --font-render-hinting=none — reduces cross-platform variance significantly but text looks slightly worse
  • Installing identical font packages everywhere — tedious but necessary. fonts-liberation + fonts-noto covers most cases
  • Running everything in the same Docker image — the nuclear option, but it works. If every environment uses the same base image, font rendering is identical

The Docker approach is what I settled on. Built a custom image with Chrome, all the fonts I need, and locked the FreeType version. Screenshots are now consistent across dev machines, CI, and production.

Curious if anyone else has run into this and found a cleaner solution. The font rendering inconsistency feels like something that should have a standard fix by now but apparently doesn't.

Side benefit of fixing this: once your baselines are stable, visual regression testing actually becomes useful instead of a noise generator.

top 1 comments
sorted by: hot top new old

For this reason, font rendering is used to fingerprint users. Unless we can force chrome to use a software renderer, there's not much you can do to get pixel perfect output. The OS, driver, graphic card, etc influence this. Maybe implement some tolerance when diffing screenshots?

this post was submitted on 21 Aug 2026
11 points (100.0% liked)

Programming

28274 readers
219 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 3 years ago
MODERATORS