diff --git a/Libraries/StyleSheet/StyleSheetTypes.js b/Libraries/StyleSheet/StyleSheetTypes.js index a78e58061d8be5..36c037e30fb63d 100644 --- a/Libraries/StyleSheet/StyleSheetTypes.js +++ b/Libraries/StyleSheet/StyleSheetTypes.js @@ -577,7 +577,16 @@ export type ____FontWeight_Internal = | '600' | '700' | '800' - | '900'; + | '900' + | 100 + | 200 + | 300 + | 400 + | 500 + | 600 + | 700 + | 800 + | 900; export type ____TextStyle_InternalCore = $ReadOnly<{ ...$Exact<____ViewStyle_Internal>, diff --git a/Libraries/Text/Text.js b/Libraries/Text/Text.js index 57b6a2ea82ca28..d2446bf53ba229 100644 --- a/Libraries/Text/Text.js +++ b/Libraries/Text/Text.js @@ -14,6 +14,7 @@ import Platform from '../Utilities/Platform'; import * as PressabilityDebug from '../Pressability/PressabilityDebug'; import usePressability from '../Pressability/usePressability'; import StyleSheet from '../StyleSheet/StyleSheet'; +import flattenStyle from '../StyleSheet/flattenStyle'; import processColor from '../StyleSheet/processColor'; import TextAncestor from './TextAncestor'; import {NativeText, NativeVirtualText} from './TextNativeComponent'; @@ -176,6 +177,12 @@ const Text: React.AbstractComponent< default: accessible, }); + let flattenedStyle = flattenStyle(style); + + if (typeof flattenedStyle?.fontWeight === 'number') { + flattenedStyle.fontWeight = flattenedStyle.fontWeight.toString(); + } + return hasTextAncestor ? ( ) : ( @@ -200,7 +207,7 @@ const Text: React.AbstractComponent< isHighlighted={isHighlighted} numberOfLines={numberOfLines} selectionColor={selectionColor} - style={style} + style={flattenedStyle} ref={forwardedRef} /> diff --git a/packages/rn-tester/js/examples/Text/TextExample.android.js b/packages/rn-tester/js/examples/Text/TextExample.android.js index 8980335aba1361..9e1b556707c9d4 100644 --- a/packages/rn-tester/js/examples/Text/TextExample.android.js +++ b/packages/rn-tester/js/examples/Text/TextExample.android.js @@ -392,6 +392,15 @@ class TextExample extends React.Component<{...}> { FONT WEIGHT 300 FONT WEIGHT 200 FONT WEIGHT 100 + FONT WEIGHT 900 + FONT WEIGHT 800 + FONT WEIGHT 700 + FONT WEIGHT 600 + FONT WEIGHT 500 + FONT WEIGHT 400 + FONT WEIGHT 300 + FONT WEIGHT 200 + FONT WEIGHT 100 Move fast and be italic diff --git a/packages/rn-tester/js/examples/Text/TextExample.ios.js b/packages/rn-tester/js/examples/Text/TextExample.ios.js index 96c19353c25c5c..c448a484baaa03 100644 --- a/packages/rn-tester/js/examples/Text/TextExample.ios.js +++ b/packages/rn-tester/js/examples/Text/TextExample.ios.js @@ -681,6 +681,15 @@ exports.examples = [ FONT WEIGHT 300 FONT WEIGHT 200 FONT WEIGHT 100 + FONT WEIGHT 900 + FONT WEIGHT 800 + FONT WEIGHT 700 + FONT WEIGHT 600 + FONT WEIGHT 500 + FONT WEIGHT 400 + FONT WEIGHT 300 + FONT WEIGHT 200 + FONT WEIGHT 100 ); },