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.
Generates a CommonJS module exposing the UniCode strings for all Font Awesome icons
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.
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.
- Generate a ZIP containing the module, up-to-date font and an example
app.js
.
Copyright 2013 Fokke Zandbergen Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.