From a2f3fa65bcabf8bb711813292002270481840579 Mon Sep 17 00:00:00 2001 From: tarunrajput Date: Mon, 30 Oct 2023 18:20:55 -0700 Subject: [PATCH] fix: textTransform not working in new arch (#41223) Summary: Fixes: https://github.com/facebook/react-native/issues/39524 ## Changelog: [ANDROID] [FIXED] - Fix textTransform not working in new architecture Pull Request resolved: https://github.com/facebook/react-native/pull/41223 Test Plan: **Before:** image **After:** image Reviewed By: javache Differential Revision: D50773216 Pulled By: NickGerleman fbshipit-source-id: 769bf67f2661ff4ff7b88121493bdd27564458d3 --- .../com/facebook/react/views/text/TextAttributeProps.java | 5 ++++- .../react/renderer/attributedstring/conversions.h | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/TextAttributeProps.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/TextAttributeProps.java index 09bddc6ea292c5..aa450d79fd2111 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/TextAttributeProps.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/TextAttributeProps.java @@ -59,6 +59,7 @@ public class TextAttributeProps { public static final short TA_KEY_ACCESSIBILITY_ROLE = 24; public static final short TA_KEY_LINE_BREAK_STRATEGY = 25; public static final short TA_KEY_ROLE = 26; + public static final short TA_KEY_TEXT_TRANSFORM = 27; public static final int UNSET = -1; @@ -217,6 +218,9 @@ public static TextAttributeProps fromMapBuffer(MapBuffer props) { case TA_KEY_ROLE: result.setRole(Role.values()[entry.getIntValue()]); break; + case TA_KEY_TEXT_TRANSFORM: + result.setTextTransform(entry.getStringValue()); + break; } } @@ -224,7 +228,6 @@ public static TextAttributeProps fromMapBuffer(MapBuffer props) { // setNumberOfLines // setColor // setIncludeFontPadding - // setTextTransform return result; } diff --git a/packages/react-native/ReactCommon/react/renderer/attributedstring/conversions.h b/packages/react-native/ReactCommon/react/renderer/attributedstring/conversions.h index 9b562666bc7992..445e452e1f4d98 100644 --- a/packages/react-native/ReactCommon/react/renderer/attributedstring/conversions.h +++ b/packages/react-native/ReactCommon/react/renderer/attributedstring/conversions.h @@ -970,6 +970,7 @@ constexpr static MapBuffer::Key TA_KEY_LAYOUT_DIRECTION = 23; constexpr static MapBuffer::Key TA_KEY_ACCESSIBILITY_ROLE = 24; constexpr static MapBuffer::Key TA_KEY_LINE_BREAK_STRATEGY = 25; constexpr static MapBuffer::Key TA_KEY_ROLE = 26; +constexpr static MapBuffer::Key TA_KEY_TEXT_TRANSFORM = 27; // constants for ParagraphAttributes serialization constexpr static MapBuffer::Key PA_KEY_MAX_NUMBER_OF_LINES = 0; @@ -1077,6 +1078,11 @@ inline MapBuffer toMapBuffer(const TextAttributes& textAttributes) { TA_KEY_LINE_BREAK_STRATEGY, toString(*textAttributes.lineBreakStrategy)); } + if (textAttributes.textTransform.has_value()) { + builder.putString( + TA_KEY_TEXT_TRANSFORM, toString(*textAttributes.textTransform)); + } + // Decoration if (textAttributes.textDecorationColor) { builder.putInt(