Support for Korean / Chinese / Japanese characters in PhantomJS

Posted by Matt Bryson on 22-Jun-2015 12:52:26
Find me on:

We use PhantomJS to auto generate images of user generated content. All was fine, until we entered the Asian markets.
It was not the usual black squares issue that you can get with Phantom, it just had spaces where the Korean characters should have been.

The font itself was loading fine, as Latin characters were in the correct type face.

After following lots of posts about installing font support packs on linux, and non of them working, I finally got it running on Centos with groupinstall for yum

sudo yum groupinstall "Korean Support" "Chinese Support" "Japanese Support"

Then we had to get this up an running on AWS on their standard Linux AMI.
As well as not supporting any Asian characters out the box, it doesn't have them in any of its Amazon repositories, so no amount of yum was going to help!

However, we did manage to register the centos repository for yum on the box, so we could install packs from that. Add this to you beanstalk configuration and it will create the centos repo file, and then install the packs.

files:
/etc/yum.repos.d/centos.repo:
mode: "000755"
owner: root
group: root
content: |
[centos]
name=CentOS $releasever - $basearch
baseurl=http://ftp.heanet.ie/pub/centos/6/os/$basearch/
enabled=1
gpgcheck=0

container_commands:
01_install_font_dependencies_for_phantomjs:
command: sudo yum -y --skip-broken groupinstall "Korean Support" "Chinese Support" "Japanese Support"
NOTE: We added the --skip-broken flag as the Chinese support has some dependency issues. Skip broken will still install most of the pack it appears, as its working, but there are clearly some aspects of it that won't work.

If you do this, i would run the command without --skip-broken and check the dependency conflicts / warnings to check it won't affect your app.

m

Topics: PhantomJS, AWS, yum, CentOS, EB (Elastic Beanstalk), Linux

About the author

Matt Bryson is an experienced systems engineer with over 15 years Development and Systems Operations experience.

NEW - Free eBook

Transforming your eDetail process. Click below to download the eBook.

New Call-to-action

Subscribe to Email Updates