CLI to convert CSS StyleSheets for Icon Fonts like FontAwesome to a CommonJS module that exports all unicodes by name. I use them in native iOS & Android apps build with Titanium.
- Input: font-awesome.css
- Output: font-awesome.js
Install the CLI via NPM like this:
$ [sudo] npm install -g iconfont
Just point the CLI to the CSS file:
$ iconfont font-awesome.css
This would create a file named font-awesome.js
in the same directory as the CSS file. If you want to write to a different path, simply pass it as the second argument:
$ iconfont font-awesome.css ~/fa.js
In Titanium, I'd use the module like this:
var icons = require('font-awesome');
var button = Ti.UI.createButton({
font: {
fontFamily: 'FontAwesome'
},
title: icons.flag
});
In Alloy you can do:
alloy.js
Alloy.Globals.icons = require('font-awesome');
index.tss
"Button": {
title: Alloy.Globals.icons.flag
}
- Icon names are camel-cased (
arrow-up
becomesarrowUp
). - If all icon names share the same prefix this will be stripped out (
icon-flag
becomesflag
). - The CLI expects selectors ending with
:before
. - The CLI expects declerations with a
content
property and a valid (unicode) string as value.
- 0.2.0:
- Adds support for non-unicode content
- Fixes camelCase for
some-1
(#3)
- 0.1.0: Initial release
Please report issues and features requests in the repo's issue tracker.
Distributed under MIT License.