Nativebase: how to define global font?

Created on 10 Jul 2016  路  10Comments  路  Source: GeekyAnts/NativeBase

There is nothing about fonts in the light.js.

Is it possible to do that?

enhancement

All 10 comments

Just setting the font as a variable won't be of much help. We'll have to include the .ttf file separately for each custom fonts. So that is not something we're looking to support in the near future. However if you do need a different font, this article might be of some help.
https://medium.com/@dabit3/adding-custom-fonts-to-react-native-b266b41bff7f#.mzhtf14we

Thanks I know how to include and use custom fonts.

What I'd like to know is how to apply that font to all NativeBase widgets.

Provided you use all the <Text> components from native-base for your app. You can define the font-family in Components/Widgets/Text.js.

Oh ok, I was hoping there was a way to do that from the theme.

Maybe you could mark this as a feature request?

There is already a custom font request. Since we want native-base to work out of the box, we can have a font variable, but how do you suggest we deal with the problem of manually adding font files?

Same as #23

Including custom font is easy.

1) Create a fonts folder in the project root.

2) Add this to package.json

  "rnpm": {
    "assets": [
      "fonts"
    ]
  }

3) rnpm link

You already have a similar procedure when installing the react-native-vector-icons dependency without the need of modifying package.json so something cleaner could be achieved.

Sounds cool. Will try it out and hopefully publish it with our next release. Appreciate the help. Thanks!

@PierBover Doesn't seem to link the fonts in iOS (0.41), got another solution you're aware off?

@benjick no, sorry.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nschurmann picture nschurmann  路  3Comments

Landerson352 picture Landerson352  路  3Comments

georgemickael-b picture georgemickael-b  路  3Comments

Cotel picture Cotel  路  3Comments

Bundas picture Bundas  路  3Comments