• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #include "bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_span_bridge.h"
16 
17 #include <string>
18 #include "base/geometry/calc_dimension.h"
19 #include "base/geometry/dimension.h"
20 #include "core/interfaces/native/node/api.h"
21 #include "bridge/declarative_frontend/engine/jsi/nativeModule/arkts_utils.h"
22 #include "core/components/common/layout/constants.h"
23 #include "core/components/text/text_theme.h"
24 #include "bridge/declarative_frontend/engine/jsi/jsi_types.h"
25 
26 
27 namespace OHOS::Ace::NG {
28 constexpr int SIZE_OF_TEXT_CASES = 2;
29 constexpr double DEFAULT_SPAN_FONT_SIZE = 16;
30 constexpr DimensionUnit DEFAULT_SPAN_FONT_UNIT = DimensionUnit::FP;
31 constexpr TextDecorationStyle DEFAULT_DECORATION_STYLE = TextDecorationStyle::SOLID;
32 constexpr Ace::FontStyle DEFAULT_FONT_STYLE = Ace::FontStyle::NORMAL;
33 constexpr Color DEFAULT_DECORATION_COLOR = Color(0xff000000);
34 const std::string DEFAULT_FONT_WEIGHT = "400";
35 constexpr int NUM_0 = 0;
36 constexpr int NUM_1 = 1;
37 constexpr int NUM_2 = 2;
38 constexpr int NUM_3 = 3;
39 constexpr int NUM_4 = 4;
40 const std::vector<OHOS::Ace::FontStyle> FONT_STYLES = { OHOS::Ace::FontStyle::NORMAL, OHOS::Ace::FontStyle::ITALIC };
41 
SetTextCase(ArkUIRuntimeCallInfo * runtimeCallInfo)42 ArkUINativeModuleValue SpanBridge::SetTextCase(ArkUIRuntimeCallInfo *runtimeCallInfo)
43 {
44     EcmaVM *vm = runtimeCallInfo->GetVM();
45     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
46     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
47     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
48     void *nativeNode = firstArg->ToNativePointer(vm)->Value();
49     if (secondArg->IsNumber() && secondArg->Int32Value(vm) >= NUM_0 &&
50         secondArg->Int32Value(vm) <= SIZE_OF_TEXT_CASES) {
51         GetArkUIInternalNodeAPI()->GetSpanModifier().SetSpanTextCase(nativeNode, secondArg->Int32Value(vm));
52     } else {
53         GetArkUIInternalNodeAPI()->GetSpanModifier().ResetSpanTextCase(nativeNode);
54     }
55     return panda::JSValueRef::Undefined(vm);
56 }
57 
ResetTextCase(ArkUIRuntimeCallInfo * runtimeCallInfo)58 ArkUINativeModuleValue SpanBridge::ResetTextCase(ArkUIRuntimeCallInfo *runtimeCallInfo)
59 {
60     EcmaVM *vm = runtimeCallInfo->GetVM();
61     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
62     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
63     void *nativeNode = firstArg->ToNativePointer(vm)->Value();
64     GetArkUIInternalNodeAPI()->GetSpanModifier().ResetSpanTextCase(nativeNode);
65     return panda::JSValueRef::Undefined(vm);
66 }
67 
SetFontWeight(ArkUIRuntimeCallInfo * runtimeCallInfo)68 ArkUINativeModuleValue SpanBridge::SetFontWeight(ArkUIRuntimeCallInfo *runtimeCallInfo)
69 {
70     EcmaVM *vm = runtimeCallInfo->GetVM();
71     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
72     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
73     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
74     void *nativeNode = firstArg->ToNativePointer(vm)->Value();
75 
76     std::string weight = DEFAULT_FONT_WEIGHT;
77     if (!secondArg->IsNull()) {
78         if (secondArg->IsNumber()) {
79             weight = std::to_string(secondArg->Int32Value(vm));
80         } else if (secondArg->IsString()) {
81             weight = secondArg->ToString(vm)->ToString();
82         }
83     }
84     GetArkUIInternalNodeAPI()->GetSpanModifier().SetSpanFontWeight(nativeNode, weight.c_str());
85     return panda::JSValueRef::Undefined(vm);
86 }
87 
ResetFontWeight(ArkUIRuntimeCallInfo * runtimeCallInfo)88 ArkUINativeModuleValue SpanBridge::ResetFontWeight(ArkUIRuntimeCallInfo *runtimeCallInfo)
89 {
90     EcmaVM *vm = runtimeCallInfo->GetVM();
91     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
92     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
93     void *nativeNode = firstArg->ToNativePointer(vm)->Value();
94     GetArkUIInternalNodeAPI()->GetSpanModifier().ResetSpanFontWeight(nativeNode);
95     return panda::JSValueRef::Undefined(vm);
96 }
97 
SetLineHeight(ArkUIRuntimeCallInfo * runtimeCallInfo)98 ArkUINativeModuleValue SpanBridge::SetLineHeight(ArkUIRuntimeCallInfo *runtimeCallInfo)
99 {
100     EcmaVM *vm = runtimeCallInfo->GetVM();
101     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
102     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
103     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
104     void *nativeNode = firstArg->ToNativePointer(vm)->Value();
105     CalcDimension lineHeight(0.0, DimensionUnit::PX);
106     if (!ArkTSUtils::ParseJsDimensionFp(vm, secondArg, lineHeight)) {
107         lineHeight.Reset();
108     }
109     GetArkUIInternalNodeAPI()->GetSpanModifier().SetSpanLineHeight(
110         nativeNode, lineHeight.Value(), static_cast<int8_t>(lineHeight.Unit()));
111     return panda::JSValueRef::Undefined(vm);
112 }
113 
ReSetLineHeight(ArkUIRuntimeCallInfo * runtimeCallInfo)114 ArkUINativeModuleValue SpanBridge::ReSetLineHeight(ArkUIRuntimeCallInfo *runtimeCallInfo)
115 {
116     EcmaVM *vm = runtimeCallInfo->GetVM();
117     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
118     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
119     void *nativeNode = firstArg->ToNativePointer(vm)->Value();
120     GetArkUIInternalNodeAPI()->GetSpanModifier().ReSetSpanLineHeight(nativeNode);
121     return panda::JSValueRef::Undefined(vm);
122 }
123 
SetFontStyle(ArkUIRuntimeCallInfo * runtimeCallInfo)124 ArkUINativeModuleValue SpanBridge::SetFontStyle(ArkUIRuntimeCallInfo *runtimeCallInfo)
125 {
126     EcmaVM *vm = runtimeCallInfo->GetVM();
127     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
128     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
129     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
130     void *nativeNode = firstArg->ToNativePointer(vm)->Value();
131     if (secondArg->IsNumber()) {
132         int32_t value = secondArg->Int32Value(vm);
133         if (value >= 0 && value < static_cast<int32_t>(FONT_STYLES.size())) {
134             GetArkUIInternalNodeAPI()->GetSpanModifier().SetSpanFontStyle(nativeNode, value);
135         } else {
136             GetArkUIInternalNodeAPI()->GetSpanModifier().ReSetSpanFontStyle(nativeNode);
137             return panda::JSValueRef::Undefined(vm);
138         }
139     } else {
140         GetArkUIInternalNodeAPI()->GetSpanModifier().ReSetSpanFontStyle(nativeNode);
141     }
142     return panda::JSValueRef::Undefined(vm);
143 }
144 
ReSetFontStyle(ArkUIRuntimeCallInfo * runtimeCallInfo)145 ArkUINativeModuleValue SpanBridge::ReSetFontStyle(ArkUIRuntimeCallInfo *runtimeCallInfo)
146 {
147     EcmaVM *vm = runtimeCallInfo->GetVM();
148     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
149     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
150     void *nativeNode = firstArg->ToNativePointer(vm)->Value();
151     GetArkUIInternalNodeAPI()->GetSpanModifier().ReSetSpanFontStyle(nativeNode);
152     return panda::JSValueRef::Undefined(vm);
153 }
154 
SetFontSize(ArkUIRuntimeCallInfo * runtimeCallInfo)155 ArkUINativeModuleValue SpanBridge::SetFontSize(ArkUIRuntimeCallInfo *runtimeCallInfo)
156 {
157     EcmaVM *vm = runtimeCallInfo->GetVM();
158     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
159     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
160     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
161     void *nativeNode = firstArg->ToNativePointer(vm)->Value();
162     auto theme = ArkTSUtils::GetTheme<TextTheme>();
163 
164     CalcDimension fontSize(DEFAULT_SPAN_FONT_SIZE, DEFAULT_SPAN_FONT_UNIT);
165     if (!ArkTSUtils::ParseJsDimensionFp(vm, secondArg, fontSize)) {
166         fontSize.SetUnit(DEFAULT_SPAN_FONT_UNIT);
167         fontSize.SetValue(DEFAULT_SPAN_FONT_SIZE);
168     }
169     if (fontSize.IsNegative() && theme) {
170         fontSize = theme->GetTextStyle().GetFontSize();
171     }
172     GetArkUIInternalNodeAPI()->GetSpanModifier().SetSpanFontSize(nativeNode, fontSize.Value(),
173         static_cast<int8_t>(fontSize.Unit()));
174     return panda::JSValueRef::Undefined(vm);
175 }
176 
ResetFontSize(ArkUIRuntimeCallInfo * runtimeCallInfo)177 ArkUINativeModuleValue SpanBridge::ResetFontSize(ArkUIRuntimeCallInfo *runtimeCallInfo)
178 {
179     EcmaVM *vm = runtimeCallInfo->GetVM();
180     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
181     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
182     void *nativeNode = firstArg->ToNativePointer(vm)->Value();
183     GetArkUIInternalNodeAPI()->GetSpanModifier().ResetSpanFontSize(nativeNode);
184     return panda::JSValueRef::Undefined(vm);
185 }
186 
SetFontFamily(ArkUIRuntimeCallInfo * runtimeCallInfo)187 ArkUINativeModuleValue SpanBridge::SetFontFamily(ArkUIRuntimeCallInfo *runtimeCallInfo)
188 {
189     EcmaVM *vm = runtimeCallInfo->GetVM();
190     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
191     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
192     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
193     void *nativeNode = firstArg->ToNativePointer(vm)->Value();
194 
195     std::vector<std::string> fontFamilies;
196     if (!ArkTSUtils::ParseJsFontFamilies(vm, secondArg, fontFamilies)) {
197         GetArkUIInternalNodeAPI()->GetSpanModifier().ResetSpanFontFamily(nativeNode);
198         return panda::JSValueRef::Undefined(vm);
199     }
200     auto families = std::make_unique<char *[]>(fontFamilies.size());
201     for (uint32_t i = 0; i < fontFamilies.size(); i++) {
202         families[i] = const_cast<char *>(fontFamilies.at(i).c_str());
203     }
204     GetArkUIInternalNodeAPI()->GetSpanModifier().SetSpanFontFamily(nativeNode,
205         const_cast<const char **>(families.get()), fontFamilies.size());
206     return panda::JSValueRef::Undefined(vm);
207 }
208 
ResetFontFamily(ArkUIRuntimeCallInfo * runtimeCallInfo)209 ArkUINativeModuleValue SpanBridge::ResetFontFamily(ArkUIRuntimeCallInfo *runtimeCallInfo)
210 {
211     EcmaVM *vm = runtimeCallInfo->GetVM();
212     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
213     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
214     void *nativeNode = firstArg->ToNativePointer(vm)->Value();
215 
216     GetArkUIInternalNodeAPI()->GetSpanModifier().ResetSpanFontFamily(nativeNode);
217     return panda::JSValueRef::Undefined(vm);
218 }
219 
SetDecoration(ArkUIRuntimeCallInfo * runtimeCallInfo)220 ArkUINativeModuleValue SpanBridge::SetDecoration(ArkUIRuntimeCallInfo *runtimeCallInfo)
221 {
222     EcmaVM *vm = runtimeCallInfo->GetVM();
223     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
224     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
225     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
226     Local<JSValueRef> thirdArg = runtimeCallInfo->GetCallArgRef(NUM_2);
227     void *nativeNode = firstArg->ToNativePointer(vm)->Value();
228     int32_t textDecoration = static_cast<int32_t>(TextDecoration::NONE);
229     Color color = DEFAULT_DECORATION_COLOR;
230     uint32_t style = static_cast<uint32_t>(DEFAULT_DECORATION_STYLE);
231     if (secondArg->IsInt()) {
232         textDecoration = secondArg->Int32Value(vm);
233     }
234     if (!ArkTSUtils::ParseJsColorAlpha(vm, thirdArg, color)) {
235         color = DEFAULT_DECORATION_COLOR;
236     }
237     GetArkUIInternalNodeAPI()->GetSpanModifier().SetSpanDecoration(
238         nativeNode, textDecoration, color.GetValue(), style);
239     return panda::JSValueRef::Undefined(vm);
240 }
241 
ResetDecoration(ArkUIRuntimeCallInfo * runtimeCallInfo)242 ArkUINativeModuleValue SpanBridge::ResetDecoration(ArkUIRuntimeCallInfo *runtimeCallInfo)
243 {
244     EcmaVM *vm = runtimeCallInfo->GetVM();
245     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
246     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
247     void *nativeNode = firstArg->ToNativePointer(vm)->Value();
248     GetArkUIInternalNodeAPI()->GetSpanModifier().ResetSpanDecoration(nativeNode);
249     return panda::JSValueRef::Undefined(vm);
250 }
251 
SetFontColor(ArkUIRuntimeCallInfo * runtimeCallInfo)252 ArkUINativeModuleValue SpanBridge::SetFontColor(ArkUIRuntimeCallInfo *runtimeCallInfo)
253 {
254     EcmaVM *vm = runtimeCallInfo->GetVM();
255     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
256     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
257     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
258     void *nativeNode = firstArg->ToNativePointer(vm)->Value();
259 
260     auto pipelineContext = PipelineBase::GetCurrentContext();
261     CHECK_NULL_RETURN(pipelineContext, panda::JSValueRef::Undefined(vm));
262     auto theme = pipelineContext->GetTheme<TextTheme>();
263     CHECK_NULL_RETURN(theme, panda::JSValueRef::Undefined(vm));
264 
265     Color textColor = theme->GetTextStyle().GetTextColor();
266     if (!ArkTSUtils::ParseJsColorAlpha(vm, secondArg, textColor)) {
267         textColor = theme->GetTextStyle().GetTextColor();
268     }
269     GetArkUIInternalNodeAPI()->GetSpanModifier().SetSpanFontColor(nativeNode, textColor.GetValue());
270     return panda::JSValueRef::Undefined(vm);
271 }
272 
ResetFontColor(ArkUIRuntimeCallInfo * runtimeCallInfo)273 ArkUINativeModuleValue SpanBridge::ResetFontColor(ArkUIRuntimeCallInfo *runtimeCallInfo)
274 {
275     EcmaVM *vm = runtimeCallInfo->GetVM();
276     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
277     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
278     void *nativeNode = firstArg->ToNativePointer(vm)->Value();
279 
280     GetArkUIInternalNodeAPI()->GetSpanModifier().ResetSpanFontColor(nativeNode);
281     return panda::JSValueRef::Undefined(vm);
282 }
283 
SetLetterSpacing(ArkUIRuntimeCallInfo * runtimeCallInfo)284 ArkUINativeModuleValue SpanBridge::SetLetterSpacing(ArkUIRuntimeCallInfo *runtimeCallInfo)
285 {
286     EcmaVM *vm = runtimeCallInfo->GetVM();
287     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
288     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
289     Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
290     void *nativeNode = firstArg->ToNativePointer(vm)->Value();
291     struct ArkUIStringAndFloat letterSpacingValue = { 0.0, nullptr };
292     if (secondArg->IsNumber()) {
293         letterSpacingValue.value = secondArg->ToNumber(vm)->Value();
294         GetArkUIInternalNodeAPI()->GetSpanModifier().SetSpanLetterSpacing(nativeNode, &letterSpacingValue);
295     } else if (secondArg->IsString()) {
296         std::string tempValueStr = secondArg->ToString(vm)->ToString();
297         letterSpacingValue.valueStr = tempValueStr.c_str();
298         GetArkUIInternalNodeAPI()->GetSpanModifier().SetSpanLetterSpacing(nativeNode, &letterSpacingValue);
299     } else {
300         GetArkUIInternalNodeAPI()->GetSpanModifier().ResetSpanLetterSpacing(nativeNode);
301     }
302     return panda::JSValueRef::Undefined(vm);
303 }
304 
ResetLetterSpacing(ArkUIRuntimeCallInfo * runtimeCallInfo)305 ArkUINativeModuleValue SpanBridge::ResetLetterSpacing(ArkUIRuntimeCallInfo *runtimeCallInfo)
306 {
307     EcmaVM *vm = runtimeCallInfo->GetVM();
308     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
309     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
310     void *nativeNode = firstArg->ToNativePointer(vm)->Value();
311     GetArkUIInternalNodeAPI()->GetSpanModifier().ResetSpanLetterSpacing(nativeNode);
312     return panda::JSValueRef::Undefined(vm);
313 }
314 
SetFont(ArkUIRuntimeCallInfo * runtimeCallInfo)315 ArkUINativeModuleValue SpanBridge::SetFont(ArkUIRuntimeCallInfo *runtimeCallInfo)
316 {
317     EcmaVM *vm = runtimeCallInfo->GetVM();
318     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
319     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
320     Local<JSValueRef> sizeArg = runtimeCallInfo->GetCallArgRef(NUM_1);
321     Local<JSValueRef> weightArg = runtimeCallInfo->GetCallArgRef(NUM_2);
322     Local<JSValueRef> familyArg = runtimeCallInfo->GetCallArgRef(NUM_3);
323     Local<JSValueRef> styleArg = runtimeCallInfo->GetCallArgRef(NUM_4);
324     void *nativeNode = firstArg->ToNativePointer(vm)->Value();
325     ArkUIFontStruct fontInfo;
326     CalcDimension fontSize;
327     if (!ArkTSUtils::ParseJsDimensionFp(vm, sizeArg,  fontSize) || sizeArg->IsNull()) {
328         fontSize.SetValue(DEFAULT_SPAN_FONT_SIZE);
329         fontSize.SetUnit(DEFAULT_SPAN_FONT_UNIT);
330     }
331     if (sizeArg->IsUndefined() || fontSize.IsNegative() || fontSize.Unit() == DimensionUnit::PERCENT) {
332         auto pipelineContext = PipelineContext::GetCurrentContext();
333         CHECK_NULL_RETURN(pipelineContext, panda::JSValueRef::Undefined(vm));
334         auto theme = pipelineContext->GetTheme<TextTheme>();
335         CHECK_NULL_RETURN(theme, panda::JSValueRef::Undefined(vm));
336         auto size = theme->GetTextStyle().GetFontSize();
337         fontInfo.fontSizeNumber = size.Value();
338         fontInfo.fontSizeUnit = static_cast<int8_t>(size.Unit());
339     } else {
340         fontInfo.fontSizeNumber = fontSize.Value();
341         fontInfo.fontSizeUnit = static_cast<int8_t>(fontSize.Unit());
342     }
343     std::string weight = DEFAULT_FONT_WEIGHT;
344     if (!weightArg->IsNull()) {
345         if (weightArg->IsNumber()) {
346             weight = std::to_string(weightArg->Int32Value(vm));
347         } else if (weightArg->IsString()) {
348             weight = weightArg->ToString(vm)->ToString();
349         }
350     }
351     fontInfo.fontWeight = static_cast<uint8_t>(Framework::ConvertStrToFontWeight(weight));
352     int32_t style = static_cast<int32_t>(DEFAULT_FONT_STYLE);
353     if (styleArg->IsInt()) {
354         style = styleArg->Int32Value(vm);
355         if (style <= 0 || style > static_cast<int32_t>(FONT_STYLES.size())) {
356             style = static_cast<int32_t>(DEFAULT_FONT_STYLE);
357         }
358     }
359     fontInfo.fontStyle = static_cast<uint8_t>(style);
360     std::vector<std::string> fontFamilies;
361     fontInfo.fontFamilies = nullptr;
362     if (!familyArg->IsNull() && ArkTSUtils::ParseJsFontFamilies(vm, familyArg, fontFamilies)) {
363         fontInfo.familyLength = fontFamilies.size();
364         auto families = std::make_unique<const char* []>(fontInfo.familyLength);
365         for (uint32_t i = 0; i < fontFamilies.size(); i++) {
366             families[i] = fontFamilies[i].c_str();
367         }
368         fontInfo.fontFamilies = families.get();
369         GetArkUIInternalNodeAPI()->GetSpanModifier().SetSpanFont(nativeNode, &fontInfo);
370     } else {
371         GetArkUIInternalNodeAPI()->GetSpanModifier().SetSpanFont(nativeNode, &fontInfo);
372     }
373     return panda::JSValueRef::Undefined(vm);
374 }
375 
ResetFont(ArkUIRuntimeCallInfo * runtimeCallInfo)376 ArkUINativeModuleValue SpanBridge::ResetFont(ArkUIRuntimeCallInfo *runtimeCallInfo)
377 {
378     EcmaVM *vm = runtimeCallInfo->GetVM();
379     CHECK_NULL_RETURN(vm, panda::NativePointerRef::New(vm, nullptr));
380     Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
381     void *nativeNode = firstArg->ToNativePointer(vm)->Value();
382     GetArkUIInternalNodeAPI()->GetSpanModifier().ResetSpanFont(nativeNode);
383     return panda::JSValueRef::Undefined(vm);
384 }
385 } // namespace OHOS::Ace::NG
386