8000 revert: "fix(core): Proper line-height calculation" (#10647) · CatchABus/NativeScript@4e54c67 · GitHub
[go: up one dir, main page]

8000
Skip to content

Commit 4e54c67

Browse files
authored
revert: "fix(core): Proper line-height calculation" (NativeScript#10647)
1 parent 4f36748 commit 4e54c67

File tree

3 files changed

+5
-16
lines changed

3 files changed

+5
-16
lines changed

packages/core/platforms/ios/src/UIView+NativeScript.m

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ - (void)nativeScriptSetTextDecorationAndTransform:(NSString*)text textDecoration
2626
BOOL isTextView = [self isKindOfClass:[UITextView class]];
2727
if (lineHeight > 0) {
2828
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
29-
// Note: Avoid using lineSpacing as it will append the height as extra space
30-
paragraphStyle.minimumLineHeight = lineHeight;
29+
paragraphStyle.lineSpacing = lineHeight;
3130
// make sure a possible previously set text alignment setting is not lost when line height is specified
3231
if ([self isKindOfClass:[UIButton class]]) {
3332
paragraphStyle.alignment = ((UIButton*)self).titleLabel.textAlignment;
@@ -89,8 +88,7 @@ -(void)nativeScriptSetFormattedTextDecorationAndTransform:(NSDictionary*)details
8988
BOOL isLabel = [self isKindOfClass:[UILabel class]];
9089
if (lineHeight > 0) {
9190
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
92-
// Note: Avoid using lineSpacing as it will append the height as extra space
93-
paragraphStyle.minimumLineHeight = lineHeight;
91+
paragraphStyle.lineSpacing = lineHeight;
9492
// make sure a possible previously set text alignment setting is not lost when line height is specified
9593
if ([self isKindOfClass:[UIButton class]]) {
9694
paragraphStyle.alignment = ((UIButton*)self).titleLabel.textAlignment;

packages/core/ui/styling/style-properties.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ export const minWidthProperty: CssProperty<Style, CoreTypes.dip | CoreTypes.Leng
7777
export const minHeightProperty: CssProperty<Style, CoreTypes.dip | CoreTypes.LengthDipUnit | CoreTypes.LengthPxUnit>;
7878
export const widthProperty: CssAnimationProperty<Style, CoreTypes.PercentLengthType>;
7979
export const heightProperty: CssAnimationProperty<Style, CoreTypes.PercentLengthType>;
80+
export const lineHeightProperty: CssProperty<Style, number>;
8081
export const marginProperty: ShorthandProperty<Style, string | CoreTypes.PercentLengthType>;
8182
export const marginLeftProperty: CssProperty<Style, CoreTypes.PercentLengthType>;
8283
export const marginRightProperty: CssProperty<Style, CoreTypes.PercentLengthType>;

packages/core/ui/text-base/index.android.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -374,20 +374,10 @@ export class TextBase extends TextBaseCommon {
374374
}
375375

376376
[lineHeightProperty.getDefault](): number {
377-
return this.nativeTextViewProtected.getLineHeight() / layout.getDisplayDensity();
377+
return this.nativeTextViewProtected.getLineSpacingExtra() / layout.getDisplayDensity();
378378
}
379379
[lineHeightProperty.setNative](value: number) {
380-
const dpValue = value * layout.getDisplayDensity();
381-
382-
if (SDK_VERSION >= 28) {
383-
this.nativeTextViewProtected.setLineHeight(dpValue);
384-
} else {
385-
const fontHeight = this.nativeTextViewProtected.getPaint().getFontMetricsInt(null);
386-
// Actual line spacing is the diff of line height and font height
387-
const lineSpacing = Math.max(dpValue - fontHeight, 0);
388-
389-
this.nativeTextViewProtected.setLineSpacing(lineSpacing, 1);
390-
}
380+
this.nativeTextViewProtected.setLineSpacing(value * layout.getDisplayDensity(), 1);
391381
}
392382

393383
[fontInternalProperty.getDefault](): android.graphics.Typeface {

0 commit comments

Comments
 (0)
0