2525import { TurboModule } from "@rnoh/react-native-openharmony/ts" ;
2626import font from '@ohos.font'
2727import measure , { MeasureOptions } from '@ohos.measure'
28- import { config } from './config ' ;
28+ import { config } from './Config ' ;
2929import display from '@ohos.display' ;
3030
3131export class RNTextSizeTurboModule extends TurboModule {
3232 measure ( options : TSMeasureParams ) : Promise < TSMeasureResult > {
3333 return new Promise < TSMeasureResult > ( ( resolve , reject ) => {
3434 try {
35- let text = options . text ;
36- let width = options . width ;
37- let lineCount = options . lineInfoForLine
35+ let lineCount = options . lineInfoForLine || 0 ;
3836 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 ,
4042 }
4143 let textSize = config ( measureText ) ;
44+ let width : number = textSize . width as number ;
4245 let height : number = textSize . height as number ;
4346 let result : TSMeasureResult = {
4447 width : width ,
@@ -61,6 +64,10 @@ export class RNTextSizeTurboModule extends TurboModule {
6164 fontHeight = text . reduce < number [ ] > ( ( prev , value ) => {
6265 let measureText : MeasureOptions = {
6366 textContent : value ,
67+ fontFamily : options . fontFamily ,
68+ fontSize : options . fontSize ,
69+ fontWeight : options . fontWeight ,
70+ letterSpacing : options . letterSpacing ,
6471 }
6572 let textSize = config ( measureText ) ;
6673 let height : number = textSize . height as number ;
0 commit comments