diff --git a/frameworks/bridge/declarative_frontend/jsview/js_text.cpp b/frameworks/bridge/declarative_frontend/jsview/js_text.cpp index aa69fe323cb3c7fd3e88512ac25749668b917479..978e2d1634d4f0c6dc59c727e193cd34134dd257 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_text.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_text.cpp @@ -193,20 +193,21 @@ void JSText::SetFontSize(const JSCallbackInfo& info) } CalcDimension fontSize; RefPtr resObj; - if (ParseJsDimensionNG(info[0], fontSize, DimensionUnit::FP, resObj, false)) { - if (SystemProperties::ConfigChangePerform() && resObj) { - RegisterResource("FontSize", resObj, fontSize); - return; - } - } else { + UnRegisterResource("FontSize"); + JSRef args = info[0]; + if (!ParseJsDimensionFpNG(args, fontSize, resObj, false) || fontSize.IsNegative()) { auto pipelineContext = PipelineContext::GetCurrentContextSafelyWithCheck(); CHECK_NULL_VOID(pipelineContext); auto theme = pipelineContext->GetTheme(); CHECK_NULL_VOID(theme); fontSize = theme->GetTextStyle().GetFontSize(); + TextModel::GetInstance()->SetFontSize(fontSize); + return; } - UnRegisterResource("FontSize"); TextModel::GetInstance()->SetFontSize(fontSize); + if (SystemProperties::ConfigChangePerform() && resObj) { + RegisterResource("FontSize", resObj, fontSize); + } } void JSText::SetFontWeight(const JSCallbackInfo& info)