Is there any way to change default font family except change native code?
I don`t want to specify font family for every Text element,It would be a mess if I do so.
Hey magicismight, thanks for reporting this issue!
React Native, as you've probably heard, is getting really popular and truth is we're getting a bit overwhelmed by the activity surrounding it. There are just too many issues for us to manage properly.
react-native or for more real time interactions, ask on Discord in the #react-native channel.resolved.
let oldRender = Text.prototype.render;
Text.prototype.render = function (...args) {
let origin = oldRender.call(this, ...args);
return cloneElement(origin, {
style: [origin.props.style, styles.defaultFontFamily]
});
};
override Text.prototype.render works for me.
It would be much better if there is an official way to resolve this
this will affect custom icon when you use icon font
How to avoid this behavior then @pannz ?
@magicismight Thank you, your solution works. But wouldn't it be better to put styles.defaultFontFamily before origin.props.style so we can customize the default font attributes?
For example:
const styles = AppStyleSheet.create({
defaultFontFamily: {
fontFamily: "Proxima Nova",
fontWeight: '300'
},
...
titleText: {
fontWeight: 'bold' <- Customize the font weight.
},
});
Most helpful comment
resolved.
override Text.prototype.render works for me.
It would be much better if there is an official way to resolve this