25
25
import { TurboModule } from "@rnoh/react-native-openharmony/ts" ;
26
26
import font from '@ohos.font'
27
27
import measure , { MeasureOptions } from '@ohos.measure'
28
- import { config } from './config ' ;
28
+ import { config } from './Config ' ;
29
29
import display from '@ohos.display' ;
30
30
31
31
export class RNTextSizeTurboModule extends TurboModule {
32
32
measure ( options : TSMeasureParams ) : Promise < TSMeasureResult > {
33
33
return new Promise < TSMeasureResult > ( ( resolve , reject ) => {
34
34
try {
35
- let text = options . text ;
36
- let width = options . width ;
37
- let lineCount = options . lineInfoForLine
35
+ let lineCount = options . lineInfoForLine || 0 ;
38
36
let measureText : MeasureOptions = {
39
- textContent : text ,
37
+ textContent : options . text ,
38
+ fontFamily : options . fontFamily ,
39
+ fontSize : options . fontSize ,
40
+ fontWeight : options . fontWeight ,
41
+ letterSpacing : options . letterSpacing ,
40
42
}
41
43
let textSize = config ( measureText ) ;
44
+ let width : number = textSize . width as number ;
42
45
let height : number = textSize . height as number ;
43
46
let result : TSMeasureResult = {
44
47
width : width ,
@@ -61,6 +64,10 @@ export class RNTextSizeTurboModule extends TurboModule {
61
64
fontHeight = text . reduce < number [ ] > ( ( prev , value ) => {
62
65
let measureText : MeasureOptions = {
63
66
textContent : value ,
67
+ fontFamily : options . fontFamily ,
68
+ fontSize : options . fontSize ,
69
+ fontWeight : options . fontWeight ,
70
+ letterSpacing : options . letterSpacing ,
64
71
}
65
72
let textSize = config ( measureText ) ;
66
73
let height : number = textSize . height as number ;
0 commit comments