diff --git a/docs/docs/components/link.md b/docs/docs/components/link.md index 5976a806c..10562a56e 100644 --- a/docs/docs/components/link.md +++ b/docs/docs/components/link.md @@ -24,6 +24,12 @@ allowFontScaling: boolean = true; // Android and iOS only // property. autoFocus: boolean = false; +// Specifies largest possible scale a font can reach when allowFontScaling is enabled. Possible values: +// - null / undefined (default): inherit from the parent node or the global default (0) +// - 0: no max, ignore parent / global default +// - >= 1: sets the maxFontSizeMultiplier of this node to this value +maxFontSizeMultiplier: number = undefined; // iOS and Android only. + // For non-zero values, truncates with ellipsis if necessary numberOfLines: number = 0; diff --git a/docs/docs/components/text.md b/docs/docs/components/text.md index ba68aef90..2a65aff86 100644 --- a/docs/docs/components/text.md +++ b/docs/docs/components/text.md @@ -54,6 +54,12 @@ accessibilityId: string = undefined; // callback. autoFocus: boolean = false; +// Specifies largest possible scale a font can reach when allowFontScaling is enabled. Possible values: +// - null / undefined (default): inherit from the parent node or the global default (0) +// - 0: no max, ignore parent / global default +// - >= 1: sets the maxFontSizeMultiplier of this node to this value +maxFontSizeMultiplier: number = undefined; // iOS and Android only. + // For non-zero values, truncates with ellipsis if necessary. Web platform // doesn't support values greater than 1. Web platform may also not truncate // properly if text contains line breaks, so it may be necessary to replace diff --git a/docs/docs/components/textinput.md b/docs/docs/components/textinput.md index f9be376d9..fee9672d4 100644 --- a/docs/docs/components/textinput.md +++ b/docs/docs/components/textinput.md @@ -65,6 +65,12 @@ keyboardAppearance: 'default' | 'light' | 'dark'; // On-screen keyboard type to display keyboardType: 'default' | 'numeric' | 'email-address' | 'number-pad'; +// Specifies largest possible scale a font can reach when allowFontScaling is enabled. Possible values: +// - null / undefined (default): inherit from the parent node or the global default (0) +// - 0: no max, ignore parent / global default +// - >= 1: sets the maxFontSizeMultiplier of this node to this value +maxFontSizeMultiplier: number = undefined; // iOS and Android only. + // Maximum character count maxLength: number = undefined; diff --git a/src/android/Text.tsx b/src/android/Text.tsx index 045edf882..3f65350e5 100644 --- a/src/android/Text.tsx +++ b/src/android/Text.tsx @@ -40,6 +40,7 @@ export class Text extends CommonText { importantForAccessibility={ importantForAccessibility } numberOfLines={ this.props.numberOfLines === 0 ? undefined : this.props.numberOfLines } allowFontScaling={ this.props.allowFontScaling } + maxFontSizeMultiplier={ this.props.maxFontSizeMultiplier } ellipsizeMode={ this.props.ellipsizeMode } onPress={ this.props.onPress } textBreakStrategy={ this.props.textBreakStrategy } diff --git a/src/common/Types.ts b/src/common/Types.ts index 72c060f6f..74a107c35 100644 --- a/src/common/Types.ts +++ b/src/common/Types.ts @@ -572,6 +572,13 @@ export interface TextPropsShared extends CommonProps { // to true. iOS and Android only. allowFontScaling?: boolean; + // Specifies largest possible scale a font can reach when allowFontScaling is enabled. Possible values: + // - null / undefined (default): inherit from the parent node or the global default (0) + // - 0: no max, ignore parent / global default + // - >= 1: sets the maxFontSizeMultiplier of this node to this value + // iOS and Android only. + maxFontSizeMultiplier?: number | null; + // iOS and Android only ellipsizeMode?: 'head' | 'middle' | 'tail'; @@ -882,6 +889,7 @@ export interface LinkProps extends CommonStyledProps selectable?: boolean; numberOfLines?: number; allowFontScaling?: boolean; + maxFontSizeMultiplier?: number | null; tabIndex?: number; accessibilityId?: string; autoFocus?: boolean; // The component is a candidate for being autofocused. @@ -914,6 +922,13 @@ export interface TextInputPropsShared extends CommonProps= 1: sets the maxFontSizeMultiplier of this node to this value + // iOS and Android only. + maxFontSizeMultiplier?: number | null; + // iOS-only prop for controlling the keyboard appearance keyboardAppearance?: 'default' | 'light' | 'dark'; diff --git a/src/native-common/Link.tsx b/src/native-common/Link.tsx index 40f1baaa5..2039e169c 100644 --- a/src/native-common/Link.tsx +++ b/src/native-common/Link.tsx @@ -48,6 +48,7 @@ export class LinkBase extends React.Component { onPress: this._onPress, onLongPress: this._onLongPress, allowFontScaling: this.props.allowFontScaling, + maxFontSizeMultiplier: this.props.maxFontSizeMultiplier, children: this.props.children, tooltip: this.props.title, testID: this.props.testId, diff --git a/src/native-common/Text.tsx b/src/native-common/Text.tsx index 47e5b351a..03b84939c 100644 --- a/src/native-common/Text.tsx +++ b/src/native-common/Text.tsx @@ -65,6 +65,7 @@ export class Text extends React.Component impl importantForAccessibility={ importantForAccessibility } numberOfLines={ this.props.numberOfLines } allowFontScaling={ this.props.allowFontScaling } + maxFontSizeMultiplier={ this.props.maxFontSizeMultiplier } onPress={ onPress } selectable={ this.props.selectable } textBreakStrategy={ 'simple' } diff --git a/src/native-common/TextInput.tsx b/src/native-common/TextInput.tsx index 08d812ba1..7129e357f 100644 --- a/src/native-common/TextInput.tsx +++ b/src/native-common/TextInput.tsx @@ -116,6 +116,7 @@ export class TextInput extends React.Component