Skip to content

Commit 068dba7

Browse files
authored
[Fabric] Implement maxFontSizeMultiplier in Text Input (#14639)
1 parent 4122500 commit 068dba7

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "[Fabric] Implement maxFontSizeMultiplier in Text Input",
4+
"packageName": "react-native-windows",
5+
"email": "54227869+anupriya13@users.noreply.github.com",
6+
"dependentChangeType": "patch"
7+
}

vnext/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,7 +1062,10 @@ void WindowsTextInputComponentView::updateProps(
10621062
oldTextInputProps.textAttributes.fontWeight != newTextInputProps.textAttributes.fontWeight ||
10631063
!facebook::react::floatEquality(
10641064
oldTextInputProps.textAttributes.letterSpacing, newTextInputProps.textAttributes.letterSpacing) ||
1065-
oldTextInputProps.textAttributes.fontFamily != newTextInputProps.textAttributes.fontFamily) {
1065+
oldTextInputProps.textAttributes.fontFamily != newTextInputProps.textAttributes.fontFamily ||
1066+
!facebook::react::floatEquality(
1067+
oldTextInputProps.textAttributes.maxFontSizeMultiplier,
1068+
newTextInputProps.textAttributes.maxFontSizeMultiplier)) {
10661069
m_propBitsMask |= TXTBIT_CHARFORMATCHANGE;
10671070
m_propBits |= TXTBIT_CHARFORMATCHANGE;
10681071
}
@@ -1422,9 +1425,15 @@ void WindowsTextInputComponentView::UpdateCharFormat() noexcept {
14221425

14231426
// set font size -- 15 to convert twips to pt
14241427
const auto &props = windowsTextInputProps();
1425-
float fontSize = m_fontSizeMultiplier *
1428+
float fontSize =
14261429
(std::isnan(props.textAttributes.fontSize) ? facebook::react::TextAttributes::defaultTextAttributes().fontSize
14271430
: props.textAttributes.fontSize);
1431+
1432+
// Apply maxFontSizeMultiplier if specified
1433+
auto maxFontSizeMultiplier = windowsTextInputProps().textAttributes.maxFontSizeMultiplier;
1434+
fontSize *=
1435+
(maxFontSizeMultiplier >= 1.0f) ? std::min(maxFontSizeMultiplier, m_fontSizeMultiplier) : m_fontSizeMultiplier;
1436+
14281437
// TODO get fontSize from props.textAttributes, or defaultTextAttributes, or fragment?
14291438
cfNew.dwMask |= CFM_SIZE;
14301439
cfNew.yHeight = static_cast<LONG>(fontSize * 15);

0 commit comments

Comments
 (0)