Awesome
NOTE
See IconFont for a Node.JS CLI that can generate a CommonJS module for any Icon Font. This repository will therefor no longer be maintained.
FontAwesomeJS
Generates a CommonJS module exposing the UniCode strings for all Font Awesome icons
Use it in a Titanium app
The module is a standard CommonJS module, but if you want to use it in Titanium apps like I do, this is how to do it:
-
Save FontAwesome.otf to
app/assets/fonts
for Alloy orResources/fonts
for classic apps.NOTE: It seems like recent versions of the FontAwesome font require the .ttf version (issue #2). Please rename to
FontAwesome.ttf
before use. -
Save http://fa.fokkezb.nl to
app/lib/fa.js
orResources
. -
Require it where you need it:
var fa = require('fa');
Or store it as a global, which in Alloy you would do in
app/alloy.js
as:Alloy.Globals.fa = require('fa');
-
Use the properties together with
FontAwesome
asfontFamily
, e.g.:'.myLabel': { font: { fontFamily: 'FontAwesome' }, text: Alloy.Globals.fa.volumeUp }
Note: This works for Ti.UI.Label
and Ti.UI.Button
, except when the button is placed in a toolbar.
How it works
The scripts reads and parses the variables.less file straight from the Font Awesome GitHub repository. It does the necessary conversion of the unicode and makes sure icon names like volume-up
also have a second object-property-friendly version, which for this one would be volumeUp
. The script caches the resulting file for 3 hours, so whenever Font Awesome adds more fonts, you'll have an up-to-date file shortly after.
Ideas
- Generate a ZIP containing the module, up-to-date font and an example
app.js
.