How to get Puppeteer to display Emojis šŸ»šŸ™‚

You're trying to get a remote Puppeteer instance to show emojis when you do a screen captureā€¦ but they are showing up as a blank square ā–”
by Jon Yongfook ·

Contents

    You're trying to get a remote Puppeteer instance to show emojis when you do a screen captureā€¦ but they are showing up as a blank square ā–”.

    Thankfully, this is a common problem with a very simple solution.

    Why does this happen?

    The blank square character shows that there is a problem.

    Unicode has two characters that indicate there is a problem with the text.

    • ā–” (WHITE SQUARE, U+25A1): Replaces a missing or unsupported Unicode character
    • ļæ½ (REPLACEMENT CHARACTER, U+FFFD): Replaces an invalid character, often due to encoding conflicts

    The latter is seen less often these days as the world has mostly converged on the unicode standard, but you will still see it if you work in a language that has multiple text encoding types e.g. Japanese

    What does the blank square mean?

    The blank square (or white square to give its official name) means that the character you are trying to display is not available in the fonts you have loaded.

    You will most often see this if you are trying to do screenshots in Puppeteer of non-latin-character language websites such as Chinese, Japanese, Arabic etc that all require special fonts to be installed.

    In the same way, you will see it if you try to do a screenshot in Puppeteer of a website using emojis, and you do not have any emoji fonts installed.

    How to fix this issue

    Simply install the fonts that Puppeteer (well, Chrome) needs to display the content. In the case of Chinese, Japanese, Arabic etc websites, install fonts in those languages.

    For emojis you will need to install an emoji font.

    A popular open source emoji font is Noto Color Emoji.

    You will need access to the linux box that Puppeteer is running on, and then installing fonts should be as easy as dropping them into somewhere like /usr/share/fonts. Start up Puppeteer again and your fonts should now fill in the blank squares!

    If you're using Puppeteer to do custom image generation in your app, try using Bannerbear instead! Your design team can set up templates, you get an API for the template, and we take care of the performance / scalability stuff!

    About the authorJon Yongfook@yongfook
    Jon is the founder of Bannerbear. He has worked as a designer and programmer for 20 years and is fascinated by the role of technology in design automation.

    Bannerbear Beginner Guide: How to Start Generating Images Dynamically in JavaScript with Bannerbear

    If you want to integrate dynamic image generation into your JavaScript project, this article is for you! Learn how to do it effortlessly with Bannerbearā€”weā€™ll walk you through the entire process, from setup and implementation to achieving the final result.

    How to Automatically Create Eye-Catching Images for Your App's Link Sharing Using Bannerbear (Node.js)

    Want to make your appā€™s link sharing stand out? Learn how to use Bannerbear to automatically create eye-catching images that boost click-through rates! This tutorial walks you through building a backend service with Node.js to automatically generate custom images based on dynamic data.

    How to Auto-Generate Social Media Posts For a Business Conference Using Bannerbear (Node.js): Part 2

    In Part 2 of our series on auto-generating social media posts for a business conference using Bannerbear, we'll be creating posts for panel sessions. The image for each post will feature key details like the session topic, moderator, and panelists.

    Automate & Scale
    Your Marketing

    Bannerbear helps you auto-generate social media visuals, banners and more with our API and nocode integrations

    How to get Puppeteer to display Emojis šŸ»šŸ™‚
    How to get Puppeteer to display Emojis šŸ»šŸ™‚