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 a8b37c1ab06896e6b6fd83fdd248bd49d7cf9b65..cc57d7a36f2f6fc5df9daea5c939b199b7451e62 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 c17661666069153c425c8e053908c903d6a6e51e..968109e66e272e9f3a2d4a43b3ec2570950e5cb0 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 ea570d0174f57689dc003dbe63167999977462fc..5c148b226534dde4eaab46de7d17ce814878cd57 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)); + 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 { - bool allowFontScaling = true; - if (textAttributes.allowFontScaling.has_value()) { - allowFontScaling = textAttributes.allowFontScaling.value(); - } + maybeThrow(NativeNodeApi::getInstance()->setLengthMetricUnit( + m_nodeHandle, ArkUI_LengthMetricUnit::ARKUI_LENGTH_METRIC_UNIT_FP)); + } - float fontSize = static_cast(textAttributes.fontSize); - 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}}}; - ArkUI_AttributeItem item = {value.data(), value.size()}; - maybeThrow(NativeNodeApi::getInstance()->setAttribute( - m_nodeHandle, NODE_FONT_SIZE, &item)); + 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)); 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 6f8b6aace9aabab68c071b782180688c001f0c0b..c52103916ecf8aa00458d02a4f639abe90d50a81 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,6 +18,7 @@ class TextInputNodeBase : public ArkUINode { TextInputNodeBase(ArkUI_NodeType nodeType); void setCommonFontAttributes( facebook::react::TextAttributes const& textAttributes); + const float defaultFontSize = 16.0; public: void setPadding(