mirror of
https://github.com/liriliri/eruda.git
synced 2026-03-20 09:38:37 +08:00
Add: Icon font
This commit is contained in:
37
script/icomoon.js
Normal file
37
script/icomoon.js
Normal file
@@ -0,0 +1,37 @@
|
||||
// Icons: ['cog']
|
||||
|
||||
var fs = require('fs'),
|
||||
path = require('path');
|
||||
|
||||
fs.readFile(path.resolve(__dirname, 'icomoon/fonts/icomoon.woff'), function (err, data)
|
||||
{
|
||||
if (err) return console.log(err);
|
||||
|
||||
genCssFile(data.toString('base64'));
|
||||
});
|
||||
|
||||
function genCssFile(fontData)
|
||||
{
|
||||
fs.readFile(path.resolve(__dirname, 'icomoon/style.css'), 'utf-8', function (err, data)
|
||||
{
|
||||
if (err) return console.log(err);
|
||||
|
||||
data = data.split('\n');
|
||||
data.splice(2, 5, ' src: url(\'data:application/x-font-woff;charset=utf-8;base64,' +
|
||||
fontData + '\') format(\'woff\');');
|
||||
data = data.join('\n');
|
||||
data = data.replace('icon-"', 'eruda-icon-"');
|
||||
|
||||
writeCssFile(data);
|
||||
});
|
||||
}
|
||||
|
||||
function writeCssFile(data)
|
||||
{
|
||||
fs.writeFile(path.resolve(__dirname, '../src/icon.css'), data, 'utf-8', function (err, data)
|
||||
{
|
||||
if (err) return console.log(err);
|
||||
|
||||
console.log('icon.css generated!');
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user