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
This commit is contained in:
David Vacca
2020-05-07 17:11:48 -07:00
committed by Facebook GitHub Bot
parent 16ea9ba813
commit 4e59508a8e
2 changed files with 14 additions and 4 deletions
@@ -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
@@ -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<facebook::react::ParagraphAttributes> {
attributes.textBreakStrategy,
attributes.adjustsFontSizeToFit,
attributes.minimumFontSize,
attributes.maximumFontSize);
attributes.maximumFontSize,
attributes.includeFontPadding);
}
};
} // namespace std