crystvis-js
Version:
A Three.js based crystallographic visualisation tool
43 lines (31 loc) • 1.04 kB
JavaScript
import generateBMFont from 'msdf-bmfont-xml';
import fs from 'fs';
import path from 'path';
import glob from 'glob';
// We update by hand whenever we want to build a new font
const fontList = [
'fonts/Rubik/static/Rubik-Medium.ttf'
];
const savePath = 'lib/assets/fonts';
// Clean up the destination path!
var old_files = glob.sync(path.join(savePath, '*.+(png|fnt)'));
old_files.forEach((fname, index) => {
fs.unlinkSync(fname);
});
for (var i in fontList) {
const fname = fontList[i];
generateBMFont(fname, (error, textures, font) => {
textures.forEach((texture, index) => {
var save = path.basename(texture.filename) + '.png';
save = path.join(savePath, save);
fs.writeFile(save, texture.texture, (err) => {
if (err) throw err;
});
});
var save = path.basename(font.filename);
save = path.join(savePath, save);
fs.writeFile(save, font.data, (err) => {
if (err) throw err;
});
});
}