Skip to content

Commit 7d9a26d

Browse files
authored
Implements italic underline and strikethrough styling for TextInput (#15563) (#15565)
* fix: Apply fontStyle italic to TextInput component * Change files * Implements underline and strikethrough styling for TextInput
1 parent c77e38a commit 7d9a26d

File tree

2 files changed

+27
-12
lines changed

2 files changed

+27
-12
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": "fix: Apply fontStyle italic to TextInput component",
4+
"packageName": "react-native-windows",
5+
"email": "74712637+iamAbhi-916@users.noreply.github.com",
6+
"dependentChangeType": "patch"
7+
}

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

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1508,18 +1508,26 @@ void WindowsTextInputComponentView::UpdateCharFormat() noexcept {
15081508
cfNew.wWeight =
15091509
props.textAttributes.fontWeight ? static_cast<WORD>(*props.textAttributes.fontWeight) : DWRITE_FONT_WEIGHT_NORMAL;
15101510

1511-
// set font style
1512-
// cfNew.dwMask |= (CFM_ITALIC | CFM_STRIKEOUT | CFM_UNDERLINE);
1513-
// int dFontStyle = fontDetails.FontStyle;
1514-
// if (dFontStyle & FS_Italic) {
1515-
// cfNew.dwEffects |= CFE_ITALIC;
1516-
// }
1517-
// if (dFontStyle & FS_StrikeOut) {
1518-
// cfNew.dwEffects |= CFE_STRIKEOUT;
1519-
//}
1520-
// if (dFontStyle & FS_Underline) {
1521-
// cfNew.dwEffects |= CFE_UNDERLINE;
1522-
// }
1511+
// set font style (italic)
1512+
cfNew.dwMask |= CFM_ITALIC;
1513+
if (props.textAttributes.fontStyle == facebook::react::FontStyle::Italic ||
1514+
props.textAttributes.fontStyle == facebook::react::FontStyle::Oblique) {
1515+
cfNew.dwEffects |= CFE_ITALIC;
1516+
}
1517+
1518+
// set text decoration (underline and strikethrough)
1519+
cfNew.dwMask |= (CFM_UNDERLINE | CFM_STRIKEOUT);
1520+
if (props.textAttributes.textDecorationLineType.has_value()) {
1521+
auto decorationType = *props.textAttributes.textDecorationLineType;
1522+
if (decorationType == facebook::react::TextDecorationLineType::Underline ||
1523+
decorationType == facebook::react::TextDecorationLineType::UnderlineStrikethrough) {
1524+
cfNew.dwEffects |= CFE_UNDERLINE;
1525+
}
1526+
if (decorationType == facebook::react::TextDecorationLineType::Strikethrough ||
1527+
decorationType == facebook::react::TextDecorationLineType::UnderlineStrikethrough) {
1528+
cfNew.dwEffects |= CFE_STRIKEOUT;
1529+
}
1530+
}
15231531

15241532
// set font family
15251533
if (!props.textAttributes.fontFamily.empty()) {

0 commit comments

Comments
 (0)