Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "[Fabric] Implement maxFontSizeMultiplier in Text Input",
"packageName": "react-native-windows",
"email": "54227869+anupriya13@users.noreply.github.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -1049,6 +1049,16 @@ void WindowsTextInputComponentView::updateProps(
m_propBits |= TXTBIT_CHARFORMATCHANGE;
}

// Uncomment below when this commit is merged in RNW:
// https://github.com/facebook/react-native/commit/97cf42f979e8303a3caeecb94cba1f5a82d1000c
// if (!facebook::react::floatEquality(
// oldTextInputProps.textAttributes.maxFontSizeMultiplier,
// newTextInputProps.textAttributes.maxFontSizeMultiplier)) {
// m_propBitsMask |= TXTBIT_CHARFORMATCHANGE;
// m_propBits |= TXTBIT_CHARFORMATCHANGE;
// m_maxFontSizeMultiplier = newTextInputProps.textAttributes.maxFontSizeMultiplier;
//}

if (oldTextInputProps.secureTextEntry != newTextInputProps.secureTextEntry) {
m_propBitsMask |= TXTBIT_USEPASSWORD;
if (newTextInputProps.secureTextEntry) {
Expand Down Expand Up @@ -1344,9 +1354,14 @@ void WindowsTextInputComponentView::UpdateCharFormat() noexcept {

// set font size -- 15 to convert twips to pt
const auto &props = windowsTextInputProps();
float fontSize = m_fontSizeMultiplier *
float fontSize =
(std::isnan(props.textAttributes.fontSize) ? facebook::react::TextAttributes::defaultTextAttributes().fontSize
: props.textAttributes.fontSize);

// Apply maxFontSizeMultiplier if specified
fontSize *= (m_maxFontSizeMultiplier >= 1.0f) ? std::min(m_maxFontSizeMultiplier, m_fontSizeMultiplier)
: m_fontSizeMultiplier;

// TODO get fontSize from props.textAttributes, or defaultTextAttributes, or fragment?
cfNew.dwMask |= CFM_SIZE;
cfNew.yHeight = static_cast<LONG>(fontSize * 15);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ struct WindowsTextInputComponentView
unsigned int m_imgWidth{0}, m_imgHeight{0};
std::shared_ptr<facebook::react::WindowsTextInputShadowNode::ConcreteState const> m_state;
float m_fontSizeMultiplier{1.0};
float m_maxFontSizeMultiplier{0.0};
int64_t m_mostRecentEventCount{0};
int m_nativeEventCount{0};
bool m_comingFromJS{false};
Expand Down
Loading