From 0c3fdfb169a22193d72e567096a653326e619f07 Mon Sep 17 00:00:00 2001 From: zhoukc42 <1540623907@qq.com> Date: Mon, 17 Feb 2025 21:09:59 +0800 Subject: [PATCH 1/5] =?UTF-8?q?fix=EF=BC=9ATextInput=E7=BB=84=E4=BB=B6allo?= =?UTF-8?q?wFontScaling=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhoukc42 <1540623907@qq.com> --- .../src/main/cpp/RNOH/arkui/TextAreaNode.cpp | 2 +- .../src/main/cpp/RNOH/arkui/TextInputNode.cpp | 2 +- .../main/cpp/RNOH/arkui/TextInputNodeBase.cpp | 25 ++++++++----------- .../main/cpp/RNOH/arkui/TextInputNodeBase.h | 3 ++- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/arkui/TextAreaNode.cpp b/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/arkui/TextAreaNode.cpp index a8b37c1a..cc57d7a3 100644 --- a/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/arkui/TextAreaNode.cpp +++ b/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/arkui/TextAreaNode.cpp @@ -171,7 +171,7 @@ void TextAreaNode::setFont( fontStyle = ARKUI_FONT_STYLE_ITALIC; } - float fontSize = 16; + float fontSize = defaultFontSize; if (!std::isnan(textAttributes.fontSize)) { fontSize = static_cast(textAttributes.fontSize); } diff --git a/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/arkui/TextInputNode.cpp b/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/arkui/TextInputNode.cpp index c1766166..968109e6 100644 --- a/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/arkui/TextInputNode.cpp +++ b/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/arkui/TextInputNode.cpp @@ -246,7 +246,7 @@ void TextInputNode::setFont( fontStyle = ARKUI_FONT_STYLE_ITALIC; } - float fontSize = 16; + float fontSize = defaultFontSize; if (!std::isnan(textAttributes.fontSize)) { fontSize = static_cast(textAttributes.fontSize); } diff --git a/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/arkui/TextInputNodeBase.cpp b/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/arkui/TextInputNodeBase.cpp index ea570d01..4997691e 100644 --- a/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/arkui/TextInputNodeBase.cpp +++ b/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/arkui/TextInputNodeBase.cpp @@ -92,29 +92,26 @@ void TextInputNodeBase::setCommonFontAttributes( m_nodeHandle, NODE_FONT_FAMILY, &item)); } - if (std::isnan(textAttributes.fontSize)) { - maybeThrow(NativeNodeApi::getInstance()->resetAttribute( - m_nodeHandle, NODE_FONT_SIZE)); - } else { bool allowFontScaling = true; if (textAttributes.allowFontScaling.has_value()) { allowFontScaling = textAttributes.allowFontScaling.value(); } - - float fontSize = static_cast(textAttributes.fontSize); if (!allowFontScaling) { - maybeThrow(NativeNodeApi::getInstance()->setLengthMetricUnit( - m_nodeHandle, ArkUI_LengthMetricUnit::ARKUI_LENGTH_METRIC_UNIT_VP)); + maybeThrow(NativeNodeApi::getInstance()->setLengthMetricUnit( + m_nodeHandle, ArkUI_LengthMetricUnit::ARKUI_LENGTH_METRIC_UNIT_VP)); } else { - maybeThrow(NativeNodeApi::getInstance()->setLengthMetricUnit( - m_nodeHandle, ArkUI_LengthMetricUnit::ARKUI_LENGTH_METRIC_UNIT_FP)); + maybeThrow(NativeNodeApi::getInstance()->setLengthMetricUnit( + m_nodeHandle, ArkUI_LengthMetricUnit::ARKUI_LENGTH_METRIC_UNIT_FP)); } - std::array value = { - {{.f32 = fontSize}}}; + + float fontSize = defaultFontSize; + if (!std::isnan(textAttributes.fontSize)) { + fontSize = static_cast(textAttributes.fontSize); + } + std::array value = {{{.f32 = fontSize}}}; ArkUI_AttributeItem item = {value.data(), value.size()}; maybeThrow(NativeNodeApi::getInstance()->setAttribute( - m_nodeHandle, NODE_FONT_SIZE, &item)); - } + m_nodeHandle, NODE_FONT_SIZE, &item)); if (textAttributes.fontWeight.has_value()) { std::array value = { diff --git a/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/arkui/TextInputNodeBase.h b/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/arkui/TextInputNodeBase.h index 6f8b6aac..7274d8e7 100644 --- a/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/arkui/TextInputNodeBase.h +++ b/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/arkui/TextInputNodeBase.h @@ -18,7 +18,8 @@ class TextInputNodeBase : public ArkUINode { TextInputNodeBase(ArkUI_NodeType nodeType); void setCommonFontAttributes( facebook::react::TextAttributes const& textAttributes); - + const float defaultFontSize = 16.0; + public: void setPadding( facebook::react::RectangleEdges padding); -- Gitee From ba3b92ce407775cf5f7303d5dbd8b3172e3c6efc Mon Sep 17 00:00:00 2001 From: zhoukc42 <1540623907@qq.com> Date: Tue, 18 Feb 2025 10:58:49 +0800 Subject: [PATCH 2/5] =?UTF-8?q?fix=EF=BC=9ATextInput=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=A0=BC=E5=BC=8F=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhoukc42 <1540623907@qq.com> --- .../src/main/cpp/RNOH/arkui/TextAreaNode.cpp | 2 +- .../src/main/cpp/RNOH/arkui/TextInputNode.cpp | 2 +- .../src/main/cpp/RNOH/arkui/TextInputNodeBase.cpp | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/arkui/TextAreaNode.cpp b/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/arkui/TextAreaNode.cpp index cc57d7a3..fb23f36d 100644 --- a/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/arkui/TextAreaNode.cpp +++ b/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/arkui/TextAreaNode.cpp @@ -171,7 +171,7 @@ void TextAreaNode::setFont( fontStyle = ARKUI_FONT_STYLE_ITALIC; } - float fontSize = defaultFontSize; + float fontSize = defaultFontSize; if (!std::isnan(textAttributes.fontSize)) { fontSize = static_cast(textAttributes.fontSize); } diff --git a/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/arkui/TextInputNode.cpp b/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/arkui/TextInputNode.cpp index 968109e6..a625c980 100644 --- a/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/arkui/TextInputNode.cpp +++ b/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/arkui/TextInputNode.cpp @@ -246,7 +246,7 @@ void TextInputNode::setFont( fontStyle = ARKUI_FONT_STYLE_ITALIC; } - float fontSize = defaultFontSize; + float fontSize = defaultFontSize; if (!std::isnan(textAttributes.fontSize)) { fontSize = static_cast(textAttributes.fontSize); } diff --git a/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/arkui/TextInputNodeBase.cpp b/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/arkui/TextInputNodeBase.cpp index 4997691e..22ac8166 100644 --- a/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/arkui/TextInputNodeBase.cpp +++ b/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/arkui/TextInputNodeBase.cpp @@ -98,10 +98,10 @@ void TextInputNodeBase::setCommonFontAttributes( } if (!allowFontScaling) { maybeThrow(NativeNodeApi::getInstance()->setLengthMetricUnit( - m_nodeHandle, ArkUI_LengthMetricUnit::ARKUI_LENGTH_METRIC_UNIT_VP)); + m_nodeHandle, ArkUI_LengthMetricUnit::ARKUI_LENGTH_METRIC_UNIT_VP)); } else { maybeThrow(NativeNodeApi::getInstance()->setLengthMetricUnit( - m_nodeHandle, ArkUI_LengthMetricUnit::ARKUI_LENGTH_METRIC_UNIT_FP)); + m_nodeHandle, ArkUI_LengthMetricUnit::ARKUI_LENGTH_METRIC_UNIT_FP)); } float fontSize = defaultFontSize; @@ -111,7 +111,7 @@ void TextInputNodeBase::setCommonFontAttributes( std::array value = {{{.f32 = fontSize}}}; ArkUI_AttributeItem item = {value.data(), value.size()}; maybeThrow(NativeNodeApi::getInstance()->setAttribute( - m_nodeHandle, NODE_FONT_SIZE, &item)); + m_nodeHandle, NODE_FONT_SIZE, &item)); if (textAttributes.fontWeight.has_value()) { std::array value = { -- Gitee From 082e9d22a0e4ae67730a12d879fc1886130fa2c8 Mon Sep 17 00:00:00 2001 From: zhoukc42 <1540623907@qq.com> Date: Tue, 18 Feb 2025 11:45:11 +0800 Subject: [PATCH 3/5] =?UTF-8?q?fix=EF=BC=9ATextInput=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=A0=BC=E5=BC=8F=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhoukc42 <1540623907@qq.com> --- .../src/main/cpp/RNOH/arkui/TextAreaNode.cpp | 40 +++++++++---------- .../src/main/cpp/RNOH/arkui/TextInputNode.cpp | 26 ++++++------ 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/arkui/TextAreaNode.cpp b/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/arkui/TextAreaNode.cpp index fb23f36d..a375a67a 100644 --- a/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/arkui/TextAreaNode.cpp +++ b/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/arkui/TextAreaNode.cpp @@ -172,27 +172,27 @@ void TextAreaNode::setFont( } float fontSize = defaultFontSize; - if (!std::isnan(textAttributes.fontSize)) { - fontSize = static_cast(textAttributes.fontSize); - } - bool allowFontScaling = true; - if (textAttributes.allowFontScaling.has_value()) { + if (!std::isnan(textAttributes.fontSize)) { + fontSize = static_cast(textAttributes.fontSize); + } + bool allowFontScaling = true; + if (textAttributes.allowFontScaling.has_value()) { allowFontScaling = textAttributes.allowFontScaling.value(); - } - if (!allowFontScaling) { - maybeThrow(NativeNodeApi::getInstance()->setLengthMetricUnit( - m_nodeHandle, ArkUI_LengthMetricUnit::ARKUI_LENGTH_METRIC_UNIT_VP)); - } else { - maybeThrow(NativeNodeApi::getInstance()->setLengthMetricUnit( - m_nodeHandle, ArkUI_LengthMetricUnit::ARKUI_LENGTH_METRIC_UNIT_FP)); - } - std::array value = { - {{.f32 = fontSize}, - {.i32 = static_cast(fontStyle)}, - {.i32 = static_cast(fontWeight)}}}; - ArkUI_AttributeItem item = {value.data(), value.size(), fontFamily.c_str()}; - maybeThrow(NativeNodeApi::getInstance()->setAttribute( - m_nodeHandle, NODE_TEXT_AREA_PLACEHOLDER_FONT, &item)); + } + if (!allowFontScaling) { + maybeThrow(NativeNodeApi::getInstance()->setLengthMetricUnit( + m_nodeHandle, ArkUI_LengthMetricUnit::ARKUI_LENGTH_METRIC_UNIT_VP)); + } else { + maybeThrow(NativeNodeApi::getInstance()->setLengthMetricUnit( + m_nodeHandle, ArkUI_LengthMetricUnit::ARKUI_LENGTH_METRIC_UNIT_FP)); + } + std::array value = { + {{.f32 = fontSize}, + {.i32 = static_cast(fontStyle)}, + {.i32 = static_cast(fontWeight)}}}; + ArkUI_AttributeItem item = {value.data(), value.size(), fontFamily.c_str()}; + maybeThrow(NativeNodeApi::getInstance()->setAttribute( + m_nodeHandle, NODE_TEXT_AREA_PLACEHOLDER_FONT, &item)); } void TextAreaNode::setCaretColor(facebook::react::SharedColor const& color) { diff --git a/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/arkui/TextInputNode.cpp b/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/arkui/TextInputNode.cpp index a625c980..8df09389 100644 --- a/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/arkui/TextInputNode.cpp +++ b/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/arkui/TextInputNode.cpp @@ -247,20 +247,20 @@ void TextInputNode::setFont( } float fontSize = defaultFontSize; - if (!std::isnan(textAttributes.fontSize)) { - fontSize = static_cast(textAttributes.fontSize); - } - bool allowFontScaling = true; - if (textAttributes.allowFontScaling.has_value()) { + if (!std::isnan(textAttributes.fontSize)) { + fontSize = static_cast(textAttributes.fontSize); + } + bool allowFontScaling = true; + if (textAttributes.allowFontScaling.has_value()) { allowFontScaling = textAttributes.allowFontScaling.value(); - } - if (!allowFontScaling) { - maybeThrow(NativeNodeApi::getInstance()->setLengthMetricUnit( - m_nodeHandle, ArkUI_LengthMetricUnit::ARKUI_LENGTH_METRIC_UNIT_VP)); - } else { - maybeThrow(NativeNodeApi::getInstance()->setLengthMetricUnit( - m_nodeHandle, ArkUI_LengthMetricUnit::ARKUI_LENGTH_METRIC_UNIT_FP)); - } + } + if (!allowFontScaling) { + maybeThrow(NativeNodeApi::getInstance()->setLengthMetricUnit( + m_nodeHandle, ArkUI_LengthMetricUnit::ARKUI_LENGTH_METRIC_UNIT_VP)); + } else { + maybeThrow(NativeNodeApi::getInstance()->setLengthMetricUnit( + m_nodeHandle, ArkUI_LengthMetricUnit::ARKUI_LENGTH_METRIC_UNIT_FP)); + } std::array value = { {{.f32 = fontSize}, -- Gitee From 055601b69b8438701312ff5a7b60d9174480f280 Mon Sep 17 00:00:00 2001 From: zhoukc42 <1540623907@qq.com> Date: Wed, 19 Feb 2025 16:19:08 +0800 Subject: [PATCH 4/5] =?UTF-8?q?fix=EF=BC=9A=E5=AF=B9=E5=B8=B8=E9=87=8F?= =?UTF-8?q?=E8=BF=9B=E8=A1=8C=E5=91=BD=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhoukc42 <1540623907@qq.com> --- .../src/main/cpp/RNOH/arkui/TextAreaNode.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/arkui/TextAreaNode.cpp b/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/arkui/TextAreaNode.cpp index a375a67a..109e6097 100644 --- a/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/arkui/TextAreaNode.cpp +++ b/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/arkui/TextAreaNode.cpp @@ -186,7 +186,8 @@ void TextAreaNode::setFont( maybeThrow(NativeNodeApi::getInstance()->setLengthMetricUnit( m_nodeHandle, ArkUI_LengthMetricUnit::ARKUI_LENGTH_METRIC_UNIT_FP)); } - std::array value = { + int32_t arraySize = 3; + std::array value = { {{.f32 = fontSize}, {.i32 = static_cast(fontStyle)}, {.i32 = static_cast(fontWeight)}}}; -- Gitee From 384b57e7668e17d4770621530950018a0c9e26d3 Mon Sep 17 00:00:00 2001 From: zhoukc42 <1540623907@qq.com> Date: Wed, 19 Feb 2025 17:27:12 +0800 Subject: [PATCH 5/5] =?UTF-8?q?fix=EF=BC=9A=E6=B7=BB=E5=8A=A0=E5=B8=B8?= =?UTF-8?q?=E9=87=8F=E4=BF=AE=E9=A5=B0=E7=AC=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhoukc42 <1540623907@qq.com> --- .../src/main/cpp/RNOH/arkui/TextAreaNode.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/arkui/TextAreaNode.cpp b/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/arkui/TextAreaNode.cpp index 109e6097..144b895a 100644 --- a/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/arkui/TextAreaNode.cpp +++ b/tester/harmony/react_native_openharmony/src/main/cpp/RNOH/arkui/TextAreaNode.cpp @@ -186,7 +186,7 @@ void TextAreaNode::setFont( maybeThrow(NativeNodeApi::getInstance()->setLengthMetricUnit( m_nodeHandle, ArkUI_LengthMetricUnit::ARKUI_LENGTH_METRIC_UNIT_FP)); } - int32_t arraySize = 3; + const int32_t arraySize = 3; std::array value = { {{.f32 = fontSize}, {.i32 = static_cast(fontStyle)}, -- Gitee