mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
custom fontWeight numeric values for Text on Android (#25341)
Summary: I found that on Android we only support 2 fontWeight options, either **normal** or **bold**, even developer can set any numeric value. But iOS supports all possible numeric values. This PR tries to add support for all possible numeric values on Android, even if it's supported only on Android P(28) and above. This change might break texts where fontWeight use improperly, because this PR removes conversion of values above 500 to BOLD and below 500 to normal. FYI, also moved **mCustomTypefaceCache** usage up because it was working after unnecessary mFontCache usage. ## Changelog [Android] [Changed] - add custom font weight support to Text component on Android, only on P(API 28) and above versions. Pull Request resolved: https://github.com/facebook/react-native/pull/25341 Test Plan: RNTester app's Text examples will show Rubik Regular, Rubik Light, Rubik Bold, Rubik Medium and Rubik Medium Italic texts in corresponding font family, style and weights. Differential Revision: D15956350 Pulled By: mdvacca fbshipit-source-id: 61079d953c65fb34ab4497d44c22317912a5a616
This commit is contained in:
committed by
Lorenzo Sciandra
parent
9792f2c9d7
commit
13f4fa0245
@@ -183,13 +183,41 @@ class TextExample extends React.Component<{}> {
|
||||
<Text style={{fontFamily: 'notoserif', fontStyle: 'italic'}}>
|
||||
NotoSerif Italic (Missing Font file)
|
||||
</Text>
|
||||
<Text style={{fontFamily: 'Srisakdi'}}>Srisakdi Regular</Text>
|
||||
<Text
|
||||
style={{
|
||||
fontFamily: 'Srisakdi',
|
||||
fontWeight: 'bold',
|
||||
fontFamily: 'Rubik',
|
||||
fontWeight: 'normal',
|
||||
}}>
|
||||
Srisakdi Bold
|
||||
Rubik Regular
|
||||
</Text>
|
||||
<Text
|
||||
style={{
|
||||
fontFamily: 'Rubik',
|
||||
fontWeight: '300',
|
||||
}}>
|
||||
Rubik Light
|
||||
</Text>
|
||||
<Text
|
||||
style={{
|
||||
fontFamily: 'Rubik',
|
||||
fontWeight: '700',
|
||||
}}>
|
||||
Rubik Bold
|
||||
</Text>
|
||||
<Text
|
||||
style={{
|
||||
fontFamily: 'Rubik',
|
||||
fontWeight: '500',
|
||||
}}>
|
||||
Rubik Medium
|
||||
</Text>
|
||||
<Text
|
||||
style={{
|
||||
fontFamily: 'Rubik',
|
||||
fontStyle: 'italic',
|
||||
fontWeight: '500',
|
||||
}}>
|
||||
Rubik Medium Italic
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
@@ -205,15 +233,15 @@ class TextExample extends React.Component<{}> {
|
||||
</RNTesterBlock>
|
||||
<RNTesterBlock title="Font Weight">
|
||||
<Text style={{fontWeight: 'bold'}}>Move fast and be bold</Text>
|
||||
<Text style={{fontWeight: 'normal'}}>Move fast and be bold</Text>
|
||||
<Text style={{fontWeight: 'normal'}}>Move fast and be normal</Text>
|
||||
</RNTesterBlock>
|
||||
<RNTesterBlock title="Font Style">
|
||||
<Text style={{fontStyle: 'italic'}}>Move fast and be bold</Text>
|
||||
<Text style={{fontStyle: 'normal'}}>Move fast and be bold</Text>
|
||||
<Text style={{fontStyle: 'italic'}}>Move fast and be italic</Text>
|
||||
<Text style={{fontStyle: 'normal'}}>Move fast and be normal</Text>
|
||||
</RNTesterBlock>
|
||||
<RNTesterBlock title="Font Style and Weight">
|
||||
<Text style={{fontStyle: 'italic', fontWeight: 'bold'}}>
|
||||
Move fast and be bold
|
||||
Move fast and be both bold and italic
|
||||
</Text>
|
||||
</RNTesterBlock>
|
||||
<RNTesterBlock title="Text Decoration">
|
||||
|
||||
Reference in New Issue
Block a user