Support minimumFontScale in paragraphAttributes (#50933)

Summary:
Support minimumFontScale in paragraphAttributes

Resolves https://github.com/facebook/react-native/issues/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: https://github.com/facebook/react-native/pull/50933

Test Plan:
Tested via this code here: https://github.com/microsoft/react-native-windows/pull/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
This commit is contained in:
Anupriya Verma
2025-04-30 05:30:19 -07:00
committed by Facebook GitHub Bot
parent 0abd5d63e1
commit f53d066d26
4 changed files with 22 additions and 2 deletions
@@ -30,7 +30,8 @@ bool ParagraphAttributes::operator==(const ParagraphAttributes& rhs) const {
rhs.includeFontPadding,
rhs.android_hyphenationFrequency) &&
floatEquality(minimumFontSize, rhs.minimumFontSize) &&
floatEquality(maximumFontSize, rhs.maximumFontSize);
floatEquality(maximumFontSize, rhs.maximumFontSize) &&
floatEquality(minimumFontScale, rhs.minimumFontScale);
}
bool ParagraphAttributes::operator!=(const ParagraphAttributes& rhs) const {
@@ -70,6 +70,12 @@ class ParagraphAttributes : public DebugStringConvertible {
Float minimumFontSize{std::numeric_limits<Float>::quiet_NaN()};
Float maximumFontSize{std::numeric_limits<Float>::quiet_NaN()};
/*
* Specifies the smallest possible scale a font can reach when
* adjustsFontSizeToFit is enabled. (values 0.01-1.0).
*/
Float minimumFontScale{std::numeric_limits<Float>::quiet_NaN()};
bool operator==(const ParagraphAttributes&) const;
bool operator!=(const ParagraphAttributes&) const;
@@ -96,7 +102,8 @@ struct hash<facebook::react::ParagraphAttributes> {
attributes.minimumFontSize,
attributes.maximumFontSize,
attributes.includeFontPadding,
attributes.android_hyphenationFrequency);
attributes.android_hyphenationFrequency,
attributes.minimumFontScale);
}
};
} // namespace std
@@ -948,6 +948,12 @@ inline ParagraphAttributes convertRawProp(
"adjustsFontSizeToFit",
sourceParagraphAttributes.adjustsFontSizeToFit,
defaultParagraphAttributes.adjustsFontSizeToFit);
paragraphAttributes.minimumFontScale = convertRawProp(
context,
rawProps,
"minimumFontScale",
sourceParagraphAttributes.minimumFontScale,
defaultParagraphAttributes.minimumFontScale);
paragraphAttributes.minimumFontSize = convertRawProp(
context,
rawProps,
@@ -96,6 +96,12 @@ void ParagraphProps::setProp(
paragraphAttributes,
adjustsFontSizeToFit,
"adjustsFontSizeToFit");
REBUILD_FIELD_SWITCH_CASE(
paDefaults,
value,
paragraphAttributes,
minimumFontScale,
"minimumFontScale");
REBUILD_FIELD_SWITCH_CASE(
paDefaults,
value,