Skip to content

Instantly share code, notes, and snippets.

@donmccurdy
Last active January 31, 2018 16:53
Show Gist options
  • Save donmccurdy/03b9e072d11c4c393415062bf3d50670 to your computer and use it in GitHub Desktop.
Save donmccurdy/03b9e072d11c4c393415062bf3d50670 to your computer and use it in GitHub Desktop.
compute engine msdf-gen setup

Installing and running msdf-bmfont-xml on Google Compute Engine.

New

Starting from Ubuntu 16.04 LTS image.

# install node.js
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
nvm install 8

# install msdf-bmfont-xml from GitHub
git clone https://github.com/soimy/msdf-bmfont-xml.git
cd msdf-bmfont-xml
npm install

# set up workspace
mkdir font_workspace
echo "你好,世界" >> font_workspace/charset.txt

# copy font from cloud storage to GCE
gsutil cp gs://donmccurdy-20180125/ttf.ttf font_workspace/yahei.ttf

# create sdf, spritesheets, and JSON manifest
node cli.js -f json -i font_workspace/charset.txt font_workspace/yahei.ttf

Old

# install node-canvas deps per https://github.com/Automattic/node-canvas/issues/524
sudo apt-get install libcairo2-dev libjpeg62-turbo-dev libpango1.0-dev libgif-dev build-essential g++

# install node
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
# maybe reconnect shell?
nvm install 8

# install msdf-bmfont-xml
npm install -g msdf-bmfont-xml

# clone and build msdfgen
# see: https://github.com/soimy/msdf-bmfont-xml/issues/17#issuecomment-360678034
git clone https://github.com/ckohnert/msdfgen.git
mkdir ./msdfgen/out && cd ./msdfgen/out && cmake .. && make
which msdf-bmfont
# should match path above, replacing bin/* with lib/node_modules/* at the end
cp msdfgen /home/donmccurdy/.nvm/versions/node/v8.9.4/lib/node_modules/msdf-bmfont-xml/bin/msdfgen.linux
cd ~

# install libpng12
# see: https://askubuntu.com/questions/840257/e-package-libpng12-0-has-no-installation-candidate-ubuntu-16-10-gnome/840268
echo "#### Manually added sources
## source for libpng12-0 package
deb http://mirrors.kernel.org/ubuntu/pool/main/libp/libpng/ xenial main" >> /etc/apt/sources.list
sudo apt-get update
sudo apt-get install libpng12-0

# set up workspace
mkdir font_workspace
echo "你好,世界" >> charset.txt

# copy font from cloud storage to GCE
gsutil cp gs://donmccurdy-20180125/ttf.ttf ./yahei.ttf

# create sdf, spritesheets, and JSON manifest
msdf-bmfont -f json -i yahei/charset.txt yahei/yahei.ttf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment