🤖 Create an engaging chatbot from scratch and add it to your NativeScript app! Learn more at our webinar on March 28th.

NativeScript Angular

User Interface Icon Fonts

While bitmap images are great, they present challenges in designing mobile applications. Images increase the size of the application if they are embedded in it. If not, they require additional http requests to be fetched. Images consume memory. Furthermore, bitmap images do not scale well. If scaled up, they lose quality. If scaled down, they waste space. On the other hand, fonts scale well, do not require additional http requests for each glyph and do not increase memory usage significantly. Icon fonts contain icons instead of alphabet characters and can be used instead of images in mobile applications.

Using Icon Fonts in NativeScript

  1. Choose or generate an icon font that best matches your needs. Two popular icon fonts are IcoMoon and Font Awesome.
  2. Once you have downloaded the icon font to your machine, locate the TrueType font file with extension .ttf.
  3. In your root application folder (This is the app folder for NativeScript Core, and the src folder for Angular 6+), create a folder called fonts and place the .ttf there.
  4. Follow the instructions on the icon font webpage to determine the hex codes of each font glyph, i.e., icon. Add a Label component to your NativeScript app and bind the Label's text property to a one-letter string generated from the character code of the icon you want to show, i.e., String.fromCharCode(0xe903).

Note: While this documentation article is focused on icon fonts, the above workflow is a hundred percent applicable for both text fonts and icon fonts.

Platform Specific Font Recognition

There is a conceptual difference in how .ttf fonts are recognized on iOS and Android. On Android, the font is recognized by its file name while on iOS it is recognized by its font name. This means that fonts that are created with a font name which is different from the file name has to be registered with both names in your CSS rule.

.fa-brands {
    font-family: "Font Awesome 5 Brands", "fa-brands-400";

In the above example, the fa-brands-400.ttf (as downloaded from the FontAwesome site) has a font name Font Awesome 5 Brands. With the above CSS, the font is recognized on both iOS (by the font name Font Awesome 5 Brands) and Android (by the file name fa-brands-400).

Note: There are specific scenarios where the creators of the fonts might have released two differently named ttf files but with the same font name (see the example below).

file name font name
fa-solid-900.ttf Font Awesome 5 Free
fa-regular-400.ttf Font Awesome 5 Free

Notice that in the above example the file names are different, but the registered font name is the same (use the Font Book application on Mac or the Control Panel Fonts section on Windows to see the actual font name). While this is no issue on Android, it renders the second font unusable on iOS. To handle similar cases additional CSS font properties, such as for example font-weight, must be added.

    File name: fa-regular-400.ttf 
    Font name: Font Awesome 5 Free
.far {
    font-family: "Font Awesome 5 Free", "fa-regular-400";
    font-weight: 400;

    File name: fa-solid-900.ttf 
    Font name: Font Awesome 5 Free
.fas {
    font-family: "Font Awesome 5 Free", "fa-solid-900";
    font-weight: 900;

Icon Fonts via HTML

<!-- FontAwesome cheatsheet glyph https://fontawesome.com/cheatsheet -->
<Label text="&#xf108;" class="fa"></Label>
.far {
    font-family: "Font Awesome 5 Free", "fa-regular-400";
    font-weight: 400;

Icon Fonts via Code-Behind

    // ...
export class IconFontComponent {
    public glyphs = new Array<{ icon: string, code: string }>();
    constructor() {
        for (let charCode = 0xe903; charCode <= 0xeaea; charCode++) {
            let glyph = {
                icon: String.fromCharCode(charCode),
                code: charCode.toString(16)
    <ListView [items]="glyphs">
        <ng-template let-item="item">
            <StackLayout orientation="horizontal">
                <Label [text]="item.icon" class="icon"></Label>
                <Label [text]="item.code"></Label>
.icon {
   font-family: 'icomoon';
   font-size: 48;

And the result is:


Example for icon font glyphs:


Example for icon font folder location: