User Agents

Web browsers and everyday web tech, explained

Fix Emojis Not Rendering in Headless Chrome

· 5 min read · Browsers

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Emojis not rendering in headless Chrome screenshots can cause visual inconsistencies, especially when generating images for social media, reports, or automated testing. This issue typically occurs because the default font configuration in headless Chrome lacks support for emoji glyphs. Fixing it involves ensuring the correct fonts are installed and accessible in the environment where Chrome runs, and configuring Chrome to use them. The solution works across Linux, Docker, and CI/CD environments where headless Chrome is commonly deployed.

What You'll Need

  • A Linux-based system or Docker container running headless Chrome (e.g., via Puppeteer, Playwright, or Selenium)
  • Root or sudo access to install system fonts (if not using Docker)
  • Basic familiarity with command-line tools and package managers (apt, apk, yum)
  • Chrome or Chromium installed in headless mode

Step-by-Step

  1. Verify emoji support in your current environment: Run a test screenshot using headless Chrome of a page containing emojis (e.g., 🎉, 😂, ❤️). If emojis appear as empty boxes, question marks, or fallback symbols, the system lacks emoji font support.
  2. Install emoji-capable fonts: On Debian/Ubuntu-based systems, install the fonts-noto-color-emoji package using the command:
    sudo apt-get update && sudo apt-get install -y fonts-noto-color-emoji
    This installs Google’s Noto Color Emoji font, which supports full-color emoji rendering.
  3. For Alpine Linux (common in Docker containers): Use the apk package manager:
    apk add --no-cache noto-fonts-emoji
    Note: Alpine may require additional font directories to be scanned. Ensure the font is in /usr/share/fonts or /usr/local/share/fonts.
  4. Refresh the font cache: After installing fonts, run:
    fc-cache -fv
    This forces the fontconfig system to re-scan available fonts and rebuild its cache, making the emoji font detectable by Chrome.
  5. Ensure Chrome uses the correct font path: Launch headless Chrome with the --font-render-hinting=medium and --disable-gpu flags if not already set. More importantly, include:
    --no-sandbox --disable-setuid-sandbox
    These are often required in containerized environments and can affect font access.
  6. Set font fallback explicitly (optional but effective): Use Chrome’s command-line flag to prioritize emoji fonts:
    --font-family="Noto Color Emoji"
    Alternatively, inject CSS in your rendered page:
    body { font-family: 'Noto Color Emoji', sans-serif; }
    This ensures emojis fall back to a supported font even if the default system font doesn’t include them.
  7. Test in a controlled HTML page: Create a minimal HTML file with visible emojis:
    <html><body>Test: 😊🎉❤️</body></html>
    Take a screenshot using your headless setup. If emojis now render correctly, the fix is working.
  8. Verify in Docker (if applicable): If using Docker, rebuild the image after installing fonts and confirm the layer includes the font package. Use docker exec [container] fc-list | grep -i emoji to verify the font is present.
  9. Adjust container permissions if needed: In some cases, Chrome running as a non-root user may not read font files. Ensure the font directory (/usr/share/fonts) has read permissions for all users:
    chmod -R a+r /usr/share/fonts
  10. Use a known-working base image (alternative): Consider using a pre-configured image like zenika/puppeteer or thegrohlm/puppeteer-aws-lambda that includes emoji fonts by default.

Common Mistakes

  • Skipping the font cache refresh (fc-cache -fv), which means Chrome never detects the new font.
  • Assuming all Linux distributions package emoji fonts the same way—Debian uses fonts-noto-color-emoji, Alpine uses noto-fonts-emoji.
  • Running Chrome without --no-sandbox in containers, which can restrict access to system resources including fonts.
  • Forgetting to rebuild Docker images after adding font installations, leading to outdated containers.
  • Using outdated versions of Chrome or Puppeteer that have known emoji rendering bugs.

Tips

  • Always test emoji rendering with a variety of emoji types (skin tones, family groups, flags) to ensure full support.
  • In CI/CD pipelines, cache the font installation step to avoid re-downloading on every run.
  • If color emojis still don’t render, check whether Chrome is running with GPU support disabled—some emoji rendering requires GPU acceleration.
  • Use Puppeteer’s emulateMedia or setContent with explicit font-family CSS to force emoji font usage.
  • Monitor Chrome version updates—some versions regress emoji support, so pin to known-working versions if necessary.

Troubleshooting

If emojis still don’t render after following the steps:

  • Check font installation: Run fc-list | grep -i emoji to confirm the emoji font is listed. If not, reinstall the font package.
  • Verify file permissions: Ensure Chrome has read access to /usr/share/fonts and subdirectories. Use ls -la /usr/share/fonts to check.
  • Test locally first: Before deploying to CI/CD, reproduce the setup on a local machine to isolate environment issues.
  • Use Chrome’s debug flags: Launch Chrome with --enable-logging --v=1 to capture logs. Look for font-related errors like Failed to load font.
  • Try a different emoji font: If Noto Color Emoji doesn’t work, test with noto-fonts or noto-fonts-extra packages.
  • Check container base image: Minimal images like alpine:latest or node:slim often lack fontconfig tools. Install fontconfig first before adding fonts.

Frequently Asked Questions

Why don’t emojis render in headless Chrome by default?

Headless Chrome environments, especially in containers, often lack emoji fonts and fontconfig tools needed to detect and render them.

Does this work with Puppeteer or Playwright?

Yes, both tools use headless Chrome. Install fonts in the host or container environment where Chrome runs.

Do I need GPU support for emojis to render?

Not always, but GPU acceleration can improve rendering. Try without --disable-gpu if possible.

Can I use a web font instead of system fonts?

Yes, but web fonts may not render in screenshots if Chrome blocks external requests. System fonts are more reliable.

Why do emojis show as black-and-white instead of color?

Color emoji support depends on the font and Chrome version. Noto Color Emoji should render in color if properly loaded.

Will this fix work in AWS Lambda or serverless environments?

Only if you can bundle fonts with your deployment package and set font paths correctly. Use pre-built layers that include fonts.