0
votes

We use PhantomJS to create screenshots from a webpage. This page displays a text which can be in any language: Latin, Russian, Chinese, Arabic etc. On my local Ubuntu desktop this all works, on the production server it displays blocks for Chinese characters. The server is AWS Linux, which is Centos-like.

The font used is Dejavu Sans:

* { font-family: "DejaVu Sans"; }

DejaVu is installed on the server:

ls -1 /usr/share/fonts/dejavu/
DejaVuSans-BoldOblique.ttf
DejaVuSans-Bold.ttf
DejaVuSansCondensed-BoldOblique.ttf
DejaVuSansCondensed-Bold.ttf
DejaVuSansCondensed-Oblique.ttf
DejaVuSansCondensed.ttf
DejaVuSans-ExtraLight.ttf
DejaVuSans-Oblique.ttf
DejaVuSans.ttf
DejaVuSerif-BoldItalic.ttf
DejaVuSerif-Bold.ttf
DejaVuSerifCondensed-BoldItalic.ttf
DejaVuSerifCondensed-Bold.ttf
DejaVuSerifCondensed-Italic.ttf
DejaVuSerifCondensed.ttf
DejaVuSerif-Italic.ttf
DejaVuSerif.ttf

Is this a font problem?

How can I get PhantomJS to display all characters?

1

1 Answers

0
votes

DejaVu has no chinese support. In fact there are almost no fonts with unicode-wide support on the market, and those few that achieved full-unicode support priorised coverage over quality (ie they look bad).

The Linux text stack is smart enough to substitute other fonts when the requested font has coverage hole, but that depends on those fonts being installed. Your desktop has a complete i18n font set installed (GUI-oriented), your server a minimal set (headless-oriented). To achieve what you want to do you need to install more fonts on your server.

And you can't just replicate your desktop font selection, font availability in a Debian derivative like Ubuntu and a Fedora derivative like AWS will be slightly different.

To check what font packages are available with coverage for a particular locale on a Fedora derivative you can type use

sudo dnf install 'font(:lang=zu)' (zulu coverage)

or something similar (replace dnf with yum if your system is older). If you want to go overboard sudo dnf install '*-fonts'. If you want to understand what font is substituted and when read fontconfig documentation (man fc-list & friends)