GithubHelp home page GithubHelp logo

Comments (14)

matrunchyk avatar matrunchyk commented on June 23, 2024 5
  1. Put your FontAwesome.ttf into app/fonts
  2. Create app/assets/font-awesome.css file with a content like the following one:
.fa {
  font-family : FontAwesome;
}

.fa-remove:before,
.fa-close:before,
.fa-times:before {
  content: "\f00d";
}

.fa-glass:before {
  content: "\f000";
}

.fa-music:before {
  content: "\f001";
}
  1. Install the package (if not installed yet): npm install nativescript-fonticon --save
  2. Change your main.js file to contain the following:
import { TNSFontIcon, fonticon } from 'nativescript-fonticon';

TNSFontIcon.debug = true;
TNSFontIcon.paths = {
  'fa': './assets/font-awesome.css',
};

// Simple variant:
// TNSFontIcon.loadCss();

// Or verbose variant:
TNSFontIcon.loadCss().then(() => {
  console.log('FontAwesome font collection loaded successfully.');
}).catch((e) => {
  console.log('Error loading FontAwesome font collection!', e.getMessage());
});

Vue.filter('fonticon', fonticon);
  1. Use it like this:
    <Label class="fa" :text="'fa-music' | fonticon"></Label>

from nativescript-fonticon.

brunnich avatar brunnich commented on June 23, 2024

Hi,
You just need to put font file in app/fonts (folder already created normally) instead of app/assets/fonts.
That's how I made it work :)

from nativescript-fonticon.

thearabbit avatar thearabbit commented on June 23, 2024

excuse me, could you example for TabViewItem

from nativescript-fonticon.

thukuwanjiku avatar thukuwanjiku commented on June 23, 2024

@matrunchyk Mine isn't working. I've tried it countless times, it doesn't work

I have both the css and .ttf files in the right directories
image

I have the package installed
image

My main.js is setup
image

But this fontawesome icon in this template
image

does not render
image

Please help.

from nativescript-fonticon.

matrunchyk avatar matrunchyk commented on June 23, 2024

@thukuwanjiku @thearabbit Did you try to name the files exactly the same as in the steps I have provided? Some browsers require the name of the font file to be exactly the same as font-family name.

from nativescript-fonticon.

thearabbit avatar thearabbit commented on June 23, 2024

This is my structure

image

// app.scss
.fa {
  font-family: FontAwesome, fontawesome-webfont;
}

// main.js
// FontAwesome
import { TNSFontIcon, fonticon } from "nativescript-fonticon";

TNSFontIcon.debug = true;
TNSFontIcon.paths = {
  fa: "./assets/styles/font-awesome.css"
};
TNSFontIcon.loadCss();
Vue.filter("fonticon", fonticon);

from nativescript-fonticon.

thukuwanjiku avatar thukuwanjiku commented on June 23, 2024

@matrunchyk I sure did, again and again, it just won't work. Perhaps if you spare a minute and build a blank app with the icons working you could share with me and have me build on top of it. I'd appreciate.

from nativescript-fonticon.

vincentderidder avatar vincentderidder commented on June 23, 2024

I cannot get it to work either. Did someone figure out how to make it work with nativescript-vue?

from nativescript-fonticon.

matrunchyk avatar matrunchyk commented on June 23, 2024

It works for me in my current project. I'll share an example with you tomorrow and will update Docs as well.

from nativescript-fonticon.

vincentderidder avatar vincentderidder commented on June 23, 2024

That would be helpfull, looking forward to it!

from nativescript-fonticon.

kstan79 avatar kstan79 commented on June 23, 2024

it doesn't work to me too.

from nativescript-fonticon.

kstan79 avatar kstan79 commented on June 23, 2024

i'm remove and rebuild entire project, it work again. Hope this help

from nativescript-fonticon.

khalidkaram avatar khalidkaram commented on June 23, 2024

I had the same issue, the problem was my webpack config.
This part was missing:

new CopyWebpackPlugin([
                { from: "fonts/**" },
                { from: "**/*.+(jpg|png)" },
                { from: "assets/**/*" },
            ], { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] }),

I hope this hep!

from nativescript-fonticon.

jbosse avatar jbosse commented on June 23, 2024

@matrunchyk thanks for the /assets tip. It seems that the underlying Nativescript file-system component cannot read files in the app root.

from nativescript-fonticon.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.