diff --git a/packages/react-native/ReactCommon/react/renderer/textlayoutmanager/TextMeasureCache.h b/packages/react-native/ReactCommon/react/renderer/textlayoutmanager/TextMeasureCache.h index b4becb8f2e10..de483900a625 100644 --- a/packages/react-native/ReactCommon/react/renderer/textlayoutmanager/TextMeasureCache.h +++ b/packages/react-native/ReactCommon/react/renderer/textlayoutmanager/TextMeasureCache.h @@ -119,6 +119,7 @@ inline bool areTextAttributesEquivalentLayoutWise(const TextAttributes &lhs, con lhs.fontStyle, lhs.fontVariant, lhs.allowFontScaling, + lhs.maxFontSizeMultiplier, lhs.dynamicTypeRamp, lhs.alignment) == std::tie( @@ -127,6 +128,7 @@ inline bool areTextAttributesEquivalentLayoutWise(const TextAttributes &lhs, con rhs.fontStyle, rhs.fontVariant, rhs.allowFontScaling, + rhs.maxFontSizeMultiplier, rhs.dynamicTypeRamp, rhs.alignment) && floatEquality(lhs.fontSize, rhs.fontSize) && floatEquality(lhs.fontSizeMultiplier, rhs.fontSizeMultiplier) && @@ -145,6 +147,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 40258861855b..ee8128be7544 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,33 @@ * LICENSE file in the root directory of this source tree. */ -#include - #include -#include +#include using namespace facebook::react; -TEST(TextLayoutManagerTest, testSomething) { - // TODO: +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)); }