Skip to content

Instantly share code, notes, and snippets.

@plusor
Forked from ipepe/install-chrome-headless.sh
Created October 29, 2020 07:56
Show Gist options
  • Save plusor/a760c1ce03907959b176ab67c208bf7f to your computer and use it in GitHub Desktop.
Save plusor/a760c1ce03907959b176ab67c208bf7f to your computer and use it in GitHub Desktop.
Installing headless chrome on Ubuntu.
#!/bin/bash
# from https://chromium.woolyss.com/
# and https://gist.github.com/addyosmani/5336747
# and https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md
sudo apt-get update
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:canonical-chromium-builds/stage
sudo apt-get update
sudo apt-get install chromium-browser
chromium-browser --headless --no-sandbox http://example.org/
@plusor
Copy link
Author

plusor commented Oct 29, 2020

https://support.google.com/chrome/thread/5705492?hl=en

I have found a solution to the problem.

It appears that Chrome in headless mode needs specific fonts installed for non-Latin characters. While this can be solved of course by installing a multitude of fonts, it would be a headache to install fonts for websites that support a lot of languages.

Luckily there are modern font packs available that cover nearly all languages and scripts on earth. I have installed 3 font packs that now show non-Latin characters for a lot of languages. For India I installed a special font pack to cover all the languages and scripts in India. I also installed a special font pack that covers Chinese Simplified, Chinese Traditional, Japanese and Korean.

Here are the 3 font packs that solve the issue. From top to bottom, an Indian font pack, an international font pack and a font pack for China, Japan and Korea:

sudo apt-get install fonts-indic
sudo apt-get install fonts-noto
sudo apt-get install fonts-noto-cjk

Installing these font packs solves the problem. And it does so elegantly. The normal Latin fonts used in the website's code still work, however when characters for a particular language can't be found, then headless Chrome falls back on the newly installed font packs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment