如何在 React Native 中设置默认字体系列?

问题描述:

React Native 中是否有与此 CSS 等效的样式,以便应用在任何地方都使用相同的字体?

Is there an equivalent to this CSS in React Native, so that the app uses the same font everywhere ?

body {
  font-family: 'Open Sans';
}

在每个 Text 节点上手动应用它似乎过于复杂.

Applying it manually on every Text node seems overly complicated.

推荐的方式是创建自己的组件,例如 MyAppText.MyAppText 将是一个简单的组件,它使用您的通用样式呈现一个 Text 组件,并且可以通过其他道具等.

The recommended way is to create your own component, such as MyAppText. MyAppText would be a simple component that renders a Text component using your universal style and can pass through other props, etc.

https://facebook.github.io/react-native/docs/text.html#limited-style-inheritance