Home

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:

  1. Save FontAwesome.otf to app/assets/fonts for Alloy or Resources/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.

  2. Save http://fa.fokkezb.nl to app/lib/fa.js or Resources.

  3. 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');
    
  4. Use the properties together with FontAwesome as fontFamily, 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

License

<pre> 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. </pre>