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..144b895a72cab6d2d401d064203e5f1df1dd24dc 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,28 +171,29 @@ void TextAreaNode::setFont( fontStyle = ARKUI_FONT_STYLE_ITALIC; } - float fontSize = 16; - if (!std::isnan(textAttributes.fontSize)) { - fontSize = static_cast(textAttributes.fontSize); - } - bool allowFontScaling = true; - if (textAttributes.allowFontScaling.has_value()) { + float fontSize = defaultFontSize; + 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)); + } + const int32_t arraySize = 3; + 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 c17661666069153c425c8e053908c903d6a6e51e..8df09389f0619e2fea70fa2d17f75fa7dbd3ddc6 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,21 +246,21 @@ void TextInputNode::setFont( fontStyle = ARKUI_FONT_STYLE_ITALIC; } - float fontSize = 16; - if (!std::isnan(textAttributes.fontSize)) { - fontSize = static_cast(textAttributes.fontSize); - } - bool allowFontScaling = true; - if (textAttributes.allowFontScaling.has_value()) { + float fontSize = defaultFontSize; + 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}, 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..22ac816608a36d094ca961e548aa10688cba12bc 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)); - } 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..7274d8e74bef5f6de231385575cfa7fd201b9f63 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);