From 83876333fa02ed18a743e55434418aa0980ef557 Mon Sep 17 00:00:00 2001 From: Anupriya Verma <54227869+anupriya13@users.noreply.github.com> Date: Fri, 25 Apr 2025 16:33:49 +0530 Subject: [PATCH 1/2] Support minimumFontScale in paragraphAttributes --- .../renderer/attributedstring/ParagraphAttributes.cpp | 3 ++- .../renderer/attributedstring/ParagraphAttributes.h | 10 +++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/react-native/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.cpp b/packages/react-native/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.cpp index b20b4c900fb9c2..9d4343b2bc25d6 100644 --- a/packages/react-native/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.cpp +++ b/packages/react-native/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.cpp @@ -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 { diff --git a/packages/react-native/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.h b/packages/react-native/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.h index d73f8632b84f6f..4edbf06677c2bf 100644 --- a/packages/react-native/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.h +++ b/packages/react-native/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.h @@ -70,6 +70,13 @@ class ParagraphAttributes : public DebugStringConvertible { Float minimumFontSize{std::numeric_limits::quiet_NaN()}; Float maximumFontSize{std::numeric_limits::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::quiet_NaN()}; + bool operator==(const ParagraphAttributes&) const; bool operator!=(const ParagraphAttributes&) const; @@ -96,7 +103,8 @@ struct hash { attributes.minimumFontSize, attributes.maximumFontSize, attributes.includeFontPadding, - attributes.android_hyphenationFrequency); + attributes.android_hyphenationFrequency, + attributes.minimumFontScale); } }; } // namespace std From c89d1682440cdda929c854c056002602b4cb911a Mon Sep 17 00:00:00 2001 From: Anupriya Verma <54227869+anupriya13@users.noreply.github.com> Date: Mon, 28 Apr 2025 10:19:30 +0530 Subject: [PATCH 2/2] Add minimumFontScale in SetProps and conversions.h --- .../react/renderer/attributedstring/conversions.h | 6 ++++++ .../react/renderer/components/text/ParagraphProps.cpp | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/packages/react-native/ReactCommon/react/renderer/attributedstring/conversions.h b/packages/react-native/ReactCommon/react/renderer/attributedstring/conversions.h index d0271c53acf9c8..bc33f7325ab978 100644 --- a/packages/react-native/ReactCommon/react/renderer/attributedstring/conversions.h +++ b/packages/react-native/ReactCommon/react/renderer/attributedstring/conversions.h @@ -921,6 +921,12 @@ inline ParagraphAttributes convertRawProp( "adjustsFontSizeToFit", sourceParagraphAttributes.adjustsFontSizeToFit, defaultParagraphAttributes.adjustsFontSizeToFit); + paragraphAttributes.minimumFontScale = convertRawProp( + context, + rawProps, + "minimumFontScale", + sourceParagraphAttributes.minimumFontScale, + defaultParagraphAttributes.minimumFontScale); paragraphAttributes.minimumFontSize = convertRawProp( context, rawProps, diff --git a/packages/react-native/ReactCommon/react/renderer/components/text/ParagraphProps.cpp b/packages/react-native/ReactCommon/react/renderer/components/text/ParagraphProps.cpp index 12e1b9780b8b9c..a483643ebdc434 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/text/ParagraphProps.cpp +++ b/packages/react-native/ReactCommon/react/renderer/components/text/ParagraphProps.cpp @@ -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,