@@ -367,14 +367,6 @@ export class TextBase extends TextBaseCommon {
367367 if ( ! this . formattedText ) {
368368 this . nativeTextViewProtected . setTextSize ( value ) ;
369369
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-
378370 // Re-calculate letter-spacing
379371 if ( this . letterSpacing != 0 ) {
380372 this . _updateLetterSpacing ( this . letterSpacing ) ;
@@ -386,12 +378,16 @@ export class TextBase extends TextBaseCommon {
386378 return this . nativeTextViewProtected . getLineHeight ( ) / layout . getDisplayDensity ( ) ;
387379 }
388380 [ 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+
391383 if ( SDK_VERSION >= 28 ) {
392- this . nativeTextViewProtected . setLineHeight ( Math . max ( value * layout . getDisplayDensity ( ) , 0 ) ) ;
384+ this . nativeTextViewProtected . setLineHeight ( dpValue ) ;
393385 } 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 ) ;
395391 }
396392 }
397393
@@ -500,15 +496,6 @@ export class TextBase extends TextBaseCommon {
500496 }
501497 }
502498
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-
512499 _updateLetterSpacing ( value : number ) : void {
513500 const emValue = value / this . fontSize ;
514501 org . nativescript . widgets . ViewHelper . setLetterspacing ( this . nativeTextViewProtected , emValue ) ;
0 commit comments