diff --git a/packages/react-native/ReactCommon/react/renderer/textlayoutmanager/TextMeasureCache.h b/packages/react-native/ReactCommon/react/renderer/textlayoutmanager/TextMeasureCache.h index b4becb8f2e1..cb3a6000c30 100644 --- a/packages/react-native/ReactCommon/react/renderer/textlayoutmanager/TextMeasureCache.h +++ b/packages/react-native/ReactCommon/react/renderer/textlayoutmanager/TextMeasureCache.h @@ -130,7 +130,8 @@ inline bool areTextAttributesEquivalentLayoutWise(const TextAttributes &lhs, con rhs.dynamicTypeRamp, rhs.alignment) && floatEquality(lhs.fontSize, rhs.fontSize) && floatEquality(lhs.fontSizeMultiplier, rhs.fontSizeMultiplier) && - floatEquality(lhs.letterSpacing, rhs.letterSpacing) && floatEquality(lhs.lineHeight, rhs.lineHeight); + floatEquality(lhs.letterSpacing, rhs.letterSpacing) && floatEquality(lhs.lineHeight, rhs.lineHeight) && + floatEquality(lhs.maxFontSizeMultiplier, rhs.maxFontSizeMultiplier); } inline size_t textAttributesHashLayoutWise(const TextAttributes &textAttributes) @@ -145,6 +146,7 @@ inline size_t textAttributesHashLayoutWise(const TextAttributes &textAttributes) textAttributes.fontStyle, textAttributes.fontVariant, textAttributes.allowFontScaling, + textAttributes.maxFontSizeMultiplier, textAttributes.dynamicTypeRamp, textAttributes.letterSpacing, textAttributes.lineHeight, diff --git a/packages/react-native/ReactCommon/react/renderer/textlayoutmanager/tests/TextLayoutManagerTest.cpp b/packages/react-native/ReactCommon/react/renderer/textlayoutmanager/tests/TextLayoutManagerTest.cpp index 40258861855..8d1152bcc9a 100644 --- a/packages/react-native/ReactCommon/react/renderer/textlayoutmanager/tests/TextLayoutManagerTest.cpp +++ b/packages/react-native/ReactCommon/react/renderer/textlayoutmanager/tests/TextLayoutManagerTest.cpp @@ -5,14 +5,42 @@ * LICENSE file in the root directory of this source tree. */ -#include - #include -#include +#include using namespace facebook::react; -TEST(TextLayoutManagerTest, testSomething) { - // TODO: +TEST(TextLayoutManagerTest, defaultTextAttributesAreLayoutEquivalent) { + TextAttributes lhs; + TextAttributes rhs; + + EXPECT_TRUE(areTextAttributesEquivalentLayoutWise(lhs, rhs)); + EXPECT_EQ( + textAttributesHashLayoutWise(lhs), textAttributesHashLayoutWise(rhs)); +} + +TEST(TextLayoutManagerTest, maxFontSizeMultiplierAffectsLayoutCacheEquality) { + TextAttributes lhs; + TextAttributes rhs; + + lhs.fontSize = rhs.fontSize = 16; + lhs.fontSizeMultiplier = rhs.fontSizeMultiplier = 2; + lhs.maxFontSizeMultiplier = 1; + rhs.maxFontSizeMultiplier = 2; + + EXPECT_FALSE(areTextAttributesEquivalentLayoutWise(lhs, rhs)); +} + +TEST(TextLayoutManagerTest, maxFontSizeMultiplierAffectsLayoutCacheHash) { + TextAttributes lhs; + TextAttributes rhs; + + lhs.fontSize = rhs.fontSize = 16; + lhs.fontSizeMultiplier = rhs.fontSizeMultiplier = 2; + lhs.maxFontSizeMultiplier = 1; + rhs.maxFontSizeMultiplier = 2; + + EXPECT_NE( + textAttributesHashLayoutWise(lhs), textAttributesHashLayoutWise(rhs)); }