@@ -367,14 +367,6 @@ export class TextBase extends TextBaseCommon {
367
367
if ( ! this . formattedText ) {
368
368
this . nativeTextViewProtected . setTextSize ( value ) ;
369
369
370
- // Re-calculate line-height
371
- if ( this . lineHeight != 0 ) {
372
- // It's done automatically for API 28+
373
- if ( SDK_VERSION < 28 ) {
374
- this . _setLineHeightLegacy ( this . lineHeight ) ;
375
- }
376
- }
377
-
378
370
// Re-calculate letter-spacing
379
371
if ( this . letterSpacing != 0 ) {
380
372
this . _updateLetterSpacing ( this . letterSpacing ) ;
@@ -386,12 +378,16 @@ export class TextBase extends TextBaseCommon {
386
378
return this . nativeTextViewProtected . getLineHeight ( ) / layout . getDisplayDensity ( ) ;
387
379
}
388
380
[ lineHeightProperty . setNative ] ( value : number ) {
389
- // Note: android throws exception in the case of negative line height
390
- // so make sure that minimum is zero
381
+ const dpValue = value * layout . getDisplayDensity ( ) ;
382
+
391
383
if ( SDK_VERSION >= 28 ) {
392
- this . nativeTextViewProtected . setLineHeight ( Math . max ( value * layout . getDisplayDensity ( ) , 0 ) ) ;
384
+ this . nativeTextViewProtected . setLineHeight ( dpValue ) ;
393
385
} else {
394
- this . _setLineHeightLegacy ( value ) ;
386
+ const fontHeight = this . nativeTextViewProtected . getPaint ( ) . getFontMetricsInt ( null ) ;
387
+ // Actual line spacing is the diff of line height and font height
388
+ const lineSpacing = Math . max ( dpValue - fontHeight , 0 ) ;
389
+
390
+ this . nativeTextViewProtected . setLineSpacing ( lineSpacing , 1 ) ;
395
391
}
396
392
}
397
393
@@ -500,15 +496,6 @@ export class TextBase extends TextBaseCommon {
500
496
}
501
497
}
502
498
503
- _setLineHeightLegacy ( value : number ) : void {
504
- const dpValue = value * layout . getDisplayDensity ( ) ;
505
- const fontHeight = this . nativeTextViewProtected . getPaint ( ) . getFontMetricsInt ( null ) ;
506
- // Actual line spacing is the diff of line height and font height
507
- const lineSpacing = Math . max ( dpValue - fontHeight , 0 ) ;
508
-
509
- this . nativeTextViewProtected . setLineSpacing ( lineSpacing , 1 ) ;
510
- }
511
-
512
499
_updateLetterSpacing ( value : number ) : void {
513
500
const emValue = value / this . fontSize ;
514
501
org . nativescript . widgets . ViewHelper . setLetterspacing ( this . nativeTextViewProtected , emValue ) ;
0 commit comments