@@ -20,6 +20,13 @@ namespace jsi = facebook::jsi;
20
20
21
21
namespace para = skia::textlayout;
22
22
23
+ bool asBool (jsi::Runtime &runtime, const jsi::Value &value) {
24
+ if (!value.isBool ()) {
25
+ throw jsi::JSError (runtime, " Expected boolean value" );
26
+ }
27
+ return value.getBool ();
28
+ }
29
+
23
30
/* *
24
31
Implementation of the TextStyle object in JSI for the paragraph builder
25
32
*/
@@ -47,7 +54,7 @@ class JsiSkStrutStyle {
47
54
48
55
if (object.hasProperty (runtime, " strutEnabled" )) {
49
56
auto propValue = object.getProperty (runtime, " strutEnabled" );
50
- retVal.setStrutEnabled (propValue. asBool ());
57
+ retVal.setStrutEnabled (asBool (runtime, propValue ));
51
58
}
52
59
if (object.hasProperty (runtime, " fontFamilies" )) {
53
60
auto propValue = object.getProperty (runtime, " fontFamilies" )
@@ -78,15 +85,15 @@ class JsiSkStrutStyle {
78
85
}
79
86
if (object.hasProperty (runtime, " halfLeading" )) {
80
87
auto propValue = object.getProperty (runtime, " halfLeading" );
81
- retVal.setHalfLeading (propValue. asBool ());
88
+ retVal.setHalfLeading (asBool (runtime, propValue ));
82
89
}
83
90
if (object.hasProperty (runtime, " leading" )) {
84
91
auto propValue = object.getProperty (runtime, " leading" );
85
92
retVal.setLeading (propValue.asNumber ());
86
93
}
87
94
if (object.hasProperty (runtime, " forceStrutHeight" )) {
88
95
auto propValue = object.getProperty (runtime, " forceStrutHeight" );
89
- retVal.setForceStrutHeight (propValue. asBool ());
96
+ retVal.setForceStrutHeight (asBool (runtime, propValue ));
90
97
}
91
98
92
99
return retVal;
0 commit comments