Search code examples
telerikiconsnativescriptnativescript-plugin

How do I use Flaticon icon fonts in NativeScript?


I have a Vanilla JavaScript NativeScript app, I'd like to use icon fonts from Flaticon, as described here, I did paste the .ttf font file, and add 'class="flaticon-airplane"' to , and I also tried giving an id to the label and apply 'font-family: "Flaticon"' style to the id, but still, did not work.


Solution

  • You can't use class name by default, you can only use the character code. If you are interested in using class names, you should also copy the CSS file and register the CSS path with nativescript-fonticon plugin.

    import * as application from 'application';
    import {TNSFontIcon, fonticon} from 'nativescript-fonticon';
    
    TNSFontIcon.paths = {
      'flaticon': 'your-flaticon-stylesheet.css'
    };
    TNSFontIcon.loadCss();
    application.setResources( { fonticon } );