Skip to content

Commit d945f4b

Browse files
authored
fix(android): lineHeight fix
1 parent bfb9db2 commit d945f4b

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/text/index.android.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ function spanToNativeString(span, parent: any, parentView: any, maxFontSize?, in
5858
if (text && textTransform != null && textTransform !== 'none') {
5959
text = getTransformedText(text, textTransform);
6060
}
61+
let lineHeightFactor = density;
6162
if (!density) {
6263
// if (!FONT_SIZE_FACTOR) {
6364
// FONT_SIZE_FACTOR = com.nativescript.text.Font.getFontSizeFactor(Utils.android.getApplicationContext()) / Screen.mainScreen.scale;
@@ -68,6 +69,9 @@ function spanToNativeString(span, parent: any, parentView: any, maxFontSize?, in
6869
// console.log('text FONT_SIZE_FACTOR', FONT_SIZE_FACTOR, Screen.mainScreen.scale)
6970
verticalTextAlignment = span.verticalAlignment || parent?.verticalAlignment;
7071
}
72+
if (density === 1) {
73+
lineHeightFactor = com.nativescript.text.Font.getFontSizeFactor(Utils.android.getApplicationContext());
74+
}
7175
let backgroundColor = span.backgroundColor || parent?.backgroundColor;
7276
if (backgroundColor && !(backgroundColor instanceof Color)) {
7377
backgroundColor = new Color(backgroundColor);
@@ -97,7 +101,7 @@ function spanToNativeString(span, parent: any, parentView: any, maxFontSize?, in
97101
relativeSize: span.relativeSize,
98102
verticalTextAlignment,
99103
linkColor: aLinkColor,
100-
lineHeight: lineHeight !== undefined ? lineHeight * density : undefined,
104+
lineHeight: lineHeight !== undefined ? lineHeight * lineHeightFactor : undefined,
101105
letterSpacing: letterSpacing !== undefined ? letterSpacing * density : undefined,
102106
color: color ? color.android : undefined,
103107
disableLinkDecoration: (span.linkDecoration && span.linkDecoration !== 'underline') || parentView?.['linkUnderline'] === false,

0 commit comments

Comments
 (0)