Skip to content

Commit f53d066

Browse files
anupriya13facebook-github-bot
authored andcommitted
Support minimumFontScale in paragraphAttributes (#50933)
Summary: Support minimumFontScale in paragraphAttributes Resolves #50934 ## Changelog: <!-- Help reviewers and the release process by writing your own changelog entry. Pick one each for the category and type tags: [GENERAL] [ADDED] - Message For more details, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> Support minimumFontScale in paragraphAttributes Pull Request resolved: #50933 Test Plan: Tested via this code here: microsoft/react-native-windows#14617 Before: ![image](https://github.com/user-attachments/assets/76b94aa8-228b-4a7e-9ec0-c366c7bf38ac) After: ![image](https://github.com/user-attachments/assets/f9fbf8c2-9776-429f-8605-5663f9c7b7c9) https://github.com/user-attachments/assets/fb9ae889-7d01-4317-a6e6-61e6b0708bc4 Reviewed By: NickGerleman Differential Revision: D73658489 Pulled By: cipolleschi fbshipit-source-id: 87ed27c0de2363e2ce0d908cc26670349586e7a6
1 parent 0abd5d6 commit f53d066

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

packages/react-native/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ bool ParagraphAttributes::operator==(const ParagraphAttributes& rhs) const {
3030
rhs.includeFontPadding,
3131
rhs.android_hyphenationFrequency) &&
3232
floatEquality(minimumFontSize, rhs.minimumFontSize) &&
33-
floatEquality(maximumFontSize, rhs.maximumFontSize);
33+
floatEquality(maximumFontSize, rhs.maximumFontSize) &&
34+
floatEquality(minimumFontScale, rhs.minimumFontScale);
3435
}
3536

3637
bool ParagraphAttributes::operator!=(const ParagraphAttributes& rhs) const {

packages/react-native/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.h

+8-1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ class ParagraphAttributes : public DebugStringConvertible {
7070
Float minimumFontSize{std::numeric_limits<Float>::quiet_NaN()};
7171
Float maximumFontSize{std::numeric_limits<Float>::quiet_NaN()};
7272

73+
/*
74+
* Specifies the smallest possible scale a font can reach when
75+
* adjustsFontSizeToFit is enabled. (values 0.01-1.0).
76+
*/
77+
Float minimumFontScale{std::numeric_limits<Float>::quiet_NaN()};
78+
7379
bool operator==(const ParagraphAttributes&) const;
7480
bool operator!=(const ParagraphAttributes&) const;
7581

@@ -96,7 +102,8 @@ struct hash<facebook::react::ParagraphAttributes> {
96102
attributes.minimumFontSize,
97103
attributes.maximumFontSize,
98104
attributes.includeFontPadding,
99-
attributes.android_hyphenationFrequency);
105+
attributes.android_hyphenationFrequency,
106+
attributes.minimumFontScale);
100107
}
101108
};
102109
} // namespace std

packages/react-native/ReactCommon/react/renderer/attributedstring/conversions.h

+6
Original file line numberDiff line numberDiff line change
@@ -948,6 +948,12 @@ inline ParagraphAttributes convertRawProp(
948948
"adjustsFontSizeToFit",
949949
sourceParagraphAttributes.adjustsFontSizeToFit,
950950
defaultParagraphAttributes.adjustsFontSizeToFit);
951+
paragraphAttributes.minimumFontScale = convertRawProp(
952+
context,
953+
rawProps,
954+
"minimumFontScale",
955+
sourceParagraphAttributes.minimumFontScale,
956+
defaultParagraphAttributes.minimumFontScale);
951957
paragraphAttributes.minimumFontSize = convertRawProp(
952958
context,
953959
rawProps,

packages/react-native/ReactCommon/react/renderer/components/text/ParagraphProps.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ void ParagraphProps::setProp(
9696
paragraphAttributes,
9797
adjustsFontSizeToFit,
9898
"adjustsFontSizeToFit");
99+
REBUILD_FIELD_SWITCH_CASE(
100+
paDefaults,
101+
value,
102+
paragraphAttributes,
103+
minimumFontScale,
104+
"minimumFontScale");
99105
REBUILD_FIELD_SWITCH_CASE(
100106
paDefaults,
101107
value,

0 commit comments

Comments
 (0)