Skip to content

Commit

Permalink
Set useLineSpacingFromFallbacks when measuring text
Browse files Browse the repository at this point in the history
Summary:
Changelog: [internal]

When paper measures text, it sets `useLineSpacingFromFallbacks` flag on the Layout object. In Fabric this was missing and can cause incorrect layout.

Reviewed By: JoshuaGross

Differential Revision: D23845441

fbshipit-source-id: 538f440cdbbf8df2cba0458837b80db103888113
  • Loading branch information
sammy-SC authored and facebook-github-bot committed Sep 23, 2020
1 parent e125f12 commit 246f746
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -326,14 +326,19 @@ private static Layout createLayout(
0.f,
includeFontPadding);
} else {
layout =
StaticLayout.Builder builder =
StaticLayout.Builder.obtain(text, 0, spanLength, textPaint, (int) width)
.setAlignment(Layout.Alignment.ALIGN_NORMAL)
.setLineSpacing(0.f, 1.f)
.setIncludePad(includeFontPadding)
.setBreakStrategy(textBreakStrategy)
.setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NORMAL)
.build();
.setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NORMAL);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
builder.setUseLineSpacingFromFallbacks(true);
}

layout = builder.build();
}
}
return layout;
Expand Down

0 comments on commit 246f746

Please sign in to comment.