mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-14 18:12:09 +08:00
revert: "fix(core): Proper line-height calculation" (#10647)
This commit is contained in:

committed by
GitHub

parent
4f367483ef
commit
4e54c676a3
@ -26,8 +26,7 @@
|
||||
BOOL isTextView = [self isKindOfClass:[UITextView class]];
|
||||
if (lineHeight > 0) {
|
||||
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
|
||||
// Note: Avoid using lineSpacing as it will append the height as extra space
|
||||
paragraphStyle.minimumLineHeight = lineHeight;
|
||||
paragraphStyle.lineSpacing = lineHeight;
|
||||
// make sure a possible previously set text alignment setting is not lost when line height is specified
|
||||
if ([self isKindOfClass:[UIButton class]]) {
|
||||
paragraphStyle.alignment = ((UIButton*)self).titleLabel.textAlignment;
|
||||
@ -89,8 +88,7 @@
|
||||
BOOL isLabel = [self isKindOfClass:[UILabel class]];
|
||||
if (lineHeight > 0) {
|
||||
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
|
||||
// Note: Avoid using lineSpacing as it will append the height as extra space
|
||||
paragraphStyle.minimumLineHeight = lineHeight;
|
||||
paragraphStyle.lineSpacing = lineHeight;
|
||||
// make sure a possible previously set text alignment setting is not lost when line height is specified
|
||||
if ([self isKindOfClass:[UIButton class]]) {
|
||||
paragraphStyle.alignment = ((UIButton*)self).titleLabel.textAlignment;
|
||||
|
@ -77,6 +77,7 @@ export const minWidthProperty: CssProperty<Style, CoreTypes.dip | CoreTypes.Leng
|
||||
export const minHeightProperty: CssProperty<Style, CoreTypes.dip | CoreTypes.LengthDipUnit | CoreTypes.LengthPxUnit>;
|
||||
export const widthProperty: CssAnimationProperty<Style, CoreTypes.PercentLengthType>;
|
||||
export const heightProperty: CssAnimationProperty<Style, CoreTypes.PercentLengthType>;
|
||||
export const lineHeightProperty: CssProperty<Style, number>;
|
||||
export const marginProperty: ShorthandProperty<Style, string | CoreTypes.PercentLengthType>;
|
||||
export const marginLeftProperty: CssProperty<Style, CoreTypes.PercentLengthType>;
|
||||
export const marginRightProperty: CssProperty<Style, CoreTypes.PercentLengthType>;
|
||||
|
@ -374,20 +374,10 @@ export class TextBase extends TextBaseCommon {
|
||||
}
|
||||
|
||||
[lineHeightProperty.getDefault](): number {
|
||||
return this.nativeTextViewProtected.getLineHeight() / layout.getDisplayDensity();
|
||||
return this.nativeTextViewProtected.getLineSpacingExtra() / layout.getDisplayDensity();
|
||||
}
|
||||
[lineHeightProperty.setNative](value: number) {
|
||||
const dpValue = value * layout.getDisplayDensity();
|
||||
|
||||
if (SDK_VERSION >= 28) {
|
||||
this.nativeTextViewProtected.setLineHeight(dpValue);
|
||||
} else {
|
||||
const fontHeight = this.nativeTextViewProtected.getPaint().getFontMetricsInt(null);
|
||||
// Actual line spacing is the diff of line height and font height
|
||||
const lineSpacing = Math.max(dpValue - fontHeight, 0);
|
||||
|
||||
this.nativeTextViewProtected.setLineSpacing(lineSpacing, 1);
|
||||
}
|
||||
this.nativeTextViewProtected.setLineSpacing(value * layout.getDisplayDensity(), 1);
|
||||
}
|
||||
|
||||
[fontInternalProperty.getDefault](): android.graphics.Typeface {
|
||||
|
Reference in New Issue
Block a user