Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
574 views
in Technique[技术] by (71.8m points)

android - How to use Font Awesome in react native project without using any third party library?

I want to use Font Awesome icons in my react-native project for android.

I want to do it manually without using any third party library like react-native-vector-icons or others.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

i am answering it for android And ios

download font awesome zip extract the files copy fontawesome-webfont.ttf file

  1. make /assets/fonts/ directory in your project directory

  2. paste fontawesome-webfont.ttf into /assets/fonts/

  3. rename the file to fontawesome.ttf

  4. add

    "rnpm": { "assets": [ "./assets/fonts/" ] } into your end of package.json file like this

enter image description here

  1. run react-native link command into terminal in your project directory

see reslut like this

rnpm-install info Linking assets to ios project
rnpm-install info Linking assets to android project
rnpm-install info Assets have been successfully linked to your project
  1. make sure run again react-native run-android command after successfully linked

go to fontawesome cheatsheet

copy only the character code of the icon you want to apply to a text view and paste it

<Text style={{ fontFamily: 'fontawesome', fontSize: 20 }}>&#xf0a9;</Text>

apply style fontFamily: 'fontawesome'

similarly you can do it for other vector icon fonts like ionicons

and others without using third party library like react-native-vector-icons


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.9k users

...