mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fix issue where text would truncate sometimes (#47294)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/47294 TextView will set `setUseLineSpacingFromFallbacks` to `true` for their `StaticLayout`s while we ignore it in this case (`false` default). The docs even recommend setting it to `true`: https://developer.android.com/reference/android/text/StaticLayout.Builder#setUseLineSpacingFromFallbacks(boolean) We set this in the `StaticLayout` builder below, but not up here so lets do that. Changelog: [Internal] Reviewed By: NickGerleman Differential Revision: D65171352 fbshipit-source-id: aa7fd116898c6af9378d71c5c570c790e6ab415f
This commit is contained in:
committed by
Facebook GitHub Bot
parent
bfca7cfe7a
commit
9f73edee2d
+8
-3
@@ -404,7 +404,7 @@ public class TextLayoutManager {
|
||||
}
|
||||
|
||||
int hintWidth = (int) Math.ceil(desiredWidth);
|
||||
layout =
|
||||
StaticLayout.Builder builder =
|
||||
StaticLayout.Builder.obtain(text, 0, spanLength, paint, hintWidth)
|
||||
.setAlignment(alignment)
|
||||
.setLineSpacing(0.f, 1.f)
|
||||
@@ -412,8 +412,13 @@ public class TextLayoutManager {
|
||||
.setBreakStrategy(textBreakStrategy)
|
||||
.setHyphenationFrequency(hyphenationFrequency)
|
||||
.setTextDirection(
|
||||
isScriptRTL ? TextDirectionHeuristics.RTL : TextDirectionHeuristics.LTR)
|
||||
.build();
|
||||
isScriptRTL ? TextDirectionHeuristics.RTL : TextDirectionHeuristics.LTR);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
builder.setUseLineSpacingFromFallbacks(true);
|
||||
}
|
||||
|
||||
layout = builder.build();
|
||||
|
||||
} else if (boring != null && (unconstrainedWidth || boring.width <= width)) {
|
||||
int boringLayoutWidth = boring.width;
|
||||
|
||||
Reference in New Issue
Block a user