Reputation: 7575
Is there a way to add custom font in React Native in Atom editor and not using Xcode?
Upvotes: 2
Views: 2765
Reputation: 1071
The way without edit package.json is:
Install in your proyect react-native-vector-icons (npm install --save react-native-vector-icons
).
Move the fonts into node_modules/react-native-vector-icons/Fonts
.
run react-native link
.
run react-native run-ios
The problem is that the name of the fonts is different than the file name. The way to show all names of the installed fonts is modify AppDelegate.m
and put the loop:
for (NSString *familyName in [UIFont familyNames]) {
for (NSString *fontName in [UIFont fontNamesForFamilyName:familyName]) {
NSLog(@"%@", fontName);
}
}
For icons fonts the name is the same.
Upvotes: 1
Reputation: 9300
There is an easier way of doing things through command line using rnpm
. It adds fonts to both android and ios. Place the font you want to add to a suitable location inside your project directory. In your package.json just add the following:
...
"rnpm": {
"assets": ["path/to/your/font/directory"]
},
...
Then from command line do: rnpm link
you can now happily use your fonts in your app.
Note: you have to have rnpm installed for this to work.
Just do npm install -g rnpm
Here is the documentation: https://github.com/rnpm/rnpm#advanced-usage
Upvotes: 5
Reputation: 364
Not Possible to add Custom Font iOS .
You are using Xcode then add Font in native app
Upvotes: 0