Home

Awesome

Ficon.as

Using this library you can easily embed and use Font Icons into your Actionscript 3 projects.

Support

Right now we support the following icon fonts:

Installation

Usage

Import the class of the font you want to use:

import com.ficon.FontAwesome;
// or import com.ficon.IconicFill;

Create a trophy icon:

var trophy:DisplayObject = FontAwesome.trophy();

Add the icon to the stage:

addChild(trophy);

Size and position it to your wishes:

trophy.y = 100;
trophy.width = 100;

It will still be rendered super-sharp since the icons are vector-based.

You can pass in options like so:

addChild(IconicStroke.camera({color: 0xFFFF00, fontSize:12}));

The options are set directly on the ElementFormat instance used. Check out the documentation for a list of possible settings.

The returned object is a FiconSprite, a descendant of Sprite. FiconSprite keeps the proportional width and height of the icon locked, so you cannot distort it. If you'd like to set width and height independently, set proportionalScaling to false:

trophy.width = 50;
trophy.height = 50;
trace(trophy.width); // Will return something like '30'

trophy.proportionalScaling = false;
trophy.width = 50;
trace(trophy.width, trophy.height) // Will return '50, 50'

UnicodeRange

Embedded fonts are usually quite large, so to minimize wasted space Ficon includes a handy feature to check what glyphs you're actually using. This way you can easily specify to only embed those, reducing filesize dramatically.

Every time you create an icon, Ficon outputs the updated unicodeRange to the console using trace, for every font you're using:

FontAwesome unicodeRange="U+f091,U+f002,U+f032,"

This includes all the glyphs you've used in Ficon. Just replace the unicodeRange in the file where the font is embedded, e.g. /com/ficon/FontAwesome.as with the generated one.

You can turn this off by setting Ficon.debug = false.

Details

We're using the Flash Text Engine (FTE) instead of regular TextFields to render the icons because this allows us to embed the fonts using CFF (embedAsCFF=true) which results in a 30% filesize reduction.

FiconSprite contains one child, a TextLine containing the glyph. Returning the TextLine object directly would be annoying if you wanted to position the element, since it calculates y using the text baseline instead of the point of the highest character, as you'd intuitively expect. IconSprite makes sure that positioning and sizing happens intuitively. If you'd like access to the TextLine, you can always get the first child of the returned FiconSprite object.

Filesize

These are based on the change in filesize of a SWF compiled with debugging off, with all the glyphs included. The overhead of the .as file is calculated by removing all but one of the icon creation functions.

Font Awesome

Total max overhead: 40KB (40381 bytes).

Iconic Fill

Total max overhead: 13KB (13543 bytes)

Iconic Stroke

Total max overhead: 13KB (13815 bytes)

Entypo

Total max overhead: 16.5KB (16468 bytes)

Todo

Attribution

This library contains some files of the following fonts. Thanks to their respective authors for providing their awesome work for free use!

Font Awesome

Font Awesome by Davy Gandy, licensed under the CC BY 3.0.

Iconic

Iconic by P.J. Onori, licensed under the CC BY-SA 3.0.

Entypo

Entypo by Daniel Bruce, licensed under the CC BY-SA 3.0.