From 4e59508a8e96d0db2861e215012df48555ab31ee Mon Sep 17 00:00:00 2001 From: David Vacca Date: Thu, 7 May 2020 17:08:17 -0700 Subject: [PATCH] Extend ParagraphAttribute to store the includeFontPadding prop Summary: This diff extends the ParagraphAttribute class to store the value of the includeFontPadding prop. Note that this is an Android only prop, I'm not creating android blocks to improve "cleanliness" of the code. changelog: [Internal][Fabric] Internal change in Fabric to support Text.includeFontPadding prop in fabric Reviewed By: shergin Differential Revision: D21446738 fbshipit-source-id: 0543e86aa18ce10f7a56bbaafe111cce0179ea86 --- .../fabric/attributedstring/ParagraphAttributes.cpp | 9 ++++++--- .../fabric/attributedstring/ParagraphAttributes.h | 9 ++++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/ReactCommon/fabric/attributedstring/ParagraphAttributes.cpp b/ReactCommon/fabric/attributedstring/ParagraphAttributes.cpp index 1cddadf5dc1..f33662b81d6 100644 --- a/ReactCommon/fabric/attributedstring/ParagraphAttributes.cpp +++ b/ReactCommon/fabric/attributedstring/ParagraphAttributes.cpp @@ -20,12 +20,14 @@ bool ParagraphAttributes::operator==(const ParagraphAttributes &rhs) const { maximumNumberOfLines, ellipsizeMode, textBreakStrategy, - adjustsFontSizeToFit) == + adjustsFontSizeToFit, + includeFontPadding) == std::tie( rhs.maximumNumberOfLines, rhs.ellipsizeMode, rhs.textBreakStrategy, - rhs.adjustsFontSizeToFit) && + rhs.adjustsFontSizeToFit, + rhs.includeFontPadding) && floatEquality(minimumFontSize, rhs.minimumFontSize) && floatEquality(maximumFontSize, rhs.maximumFontSize); } @@ -44,7 +46,8 @@ SharedDebugStringConvertibleList ParagraphAttributes::getDebugProps() const { debugStringConvertibleItem("textBreakStrategy", textBreakStrategy), debugStringConvertibleItem("adjustsFontSizeToFit", adjustsFontSizeToFit), debugStringConvertibleItem("minimumFontSize", minimumFontSize), - debugStringConvertibleItem("maximumFontSize", maximumFontSize)}; + debugStringConvertibleItem("maximumFontSize", maximumFontSize), + debugStringConvertibleItem("includeFontPadding", includeFontPadding)}; } #endif diff --git a/ReactCommon/fabric/attributedstring/ParagraphAttributes.h b/ReactCommon/fabric/attributedstring/ParagraphAttributes.h index acc7636a655..58569603361 100644 --- a/ReactCommon/fabric/attributedstring/ParagraphAttributes.h +++ b/ReactCommon/fabric/attributedstring/ParagraphAttributes.h @@ -49,6 +49,12 @@ class ParagraphAttributes : public DebugStringConvertible { */ bool adjustsFontSizeToFit{}; + /* + * (Android only) Leaves enough room for ascenders and descenders instead of + * using the font ascent and descent strictly. + */ + bool includeFontPadding{true}; + /* * In case of font size adjustment enabled, defines minimum and maximum * font sizes. @@ -82,7 +88,8 @@ struct hash { attributes.textBreakStrategy, attributes.adjustsFontSizeToFit, attributes.minimumFontSize, - attributes.maximumFontSize); + attributes.maximumFontSize, + attributes.includeFontPadding); } }; } // namespace std