Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix single line text not fully rendered #41770

Open
wants to merge 38 commits into
base: main
Choose a base branch
from
Open
Changes from 25 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
ee78c64
minimum repro
fabOnReact Nov 21, 2023
5ae2022
minimum repro
fabOnReact Nov 22, 2023
2dbbd2c
fix issue with layout
fabOnReact Nov 28, 2023
86fb167
commit example
fabOnReact Nov 28, 2023
52ba803
revert changes to RNTesterAppShared
fabOnReact Nov 28, 2023
dbc25ea
disable fabric
fabOnReact Nov 28, 2023
cc61712
final commit
fabOnReact Nov 28, 2023
9259392
minimum repro
fabOnReact Nov 28, 2023
62e950d
remove example
fabOnReact Nov 29, 2023
419b9ca
Merge branch 'main' into title-not-full-width
fabOnReact Nov 29, 2023
6ba5740
minor change
fabOnReact Nov 29, 2023
bf5c65e
using BoringLayout for single line text
fabOnReact Nov 30, 2023
1a187df
additional check on text length
fabOnReact Nov 30, 2023
c6f4bff
refactor requiresBorignLayout condition
fabOnReact Nov 30, 2023
9ec1575
rename condition
fabOnReact Nov 30, 2023
a188237
Merge branch 'main' into title-not-full-width
fabOnReact Dec 1, 2023
ee9c6a0
Use layout.getWidth when numberOfLines is set to 1
fabOnReact Dec 2, 2023
e34e67b
clean up
fabOnReact Dec 2, 2023
008b6ea
reintroduce boringlayout solution instead of getWidth
fabOnReact Dec 2, 2023
b9ffa4e
enable new arch
fabOnReact Dec 2, 2023
a668073
Merge branch 'main' into title-not-full-width
fabOnReact Dec 3, 2023
1c9cb3e
using not operator
fabOnReact Dec 3, 2023
08552f9
refactor if condition
fabOnReact Dec 3, 2023
0be9d73
update comments
fabOnReact Dec 3, 2023
18a40d8
refactor if statement
fabOnReact Dec 3, 2023
9a96f26
Merge branch 'main' into title-not-full-width
fabOnReact Feb 29, 2024
7c43320
use StaticLayout instead of boring layout
fabOnReact Feb 29, 2024
87ee351
remove overrideTextBreakStrategySingleLine variable
fabOnReact Feb 29, 2024
8737536
adding fix for fabric
fabOnReact Feb 29, 2024
00c318c
update attachmentPosition logic for inline Images in TextLayoutManager
fabOnReact Mar 2, 2024
0da2607
commit before change branch
fabOnReact Mar 4, 2024
a48926d
Revert "commit before change branch"
fabOnReact Mar 4, 2024
1ec6a32
avoid check on calculatedLineCount
fabOnReact Mar 4, 2024
90063ba
change calculatedLineCount to maximumNumberOfLines on paper
fabOnReact Mar 4, 2024
c336609
Merge branch 'main' into title-not-full-width
fabOnReact Mar 5, 2024
05b3e2b
Merge branch 'main' into title-not-full-width
fabOnReact Mar 10, 2024
d37438c
Merge branch 'main' into title-not-full-width
fabOnReact May 14, 2024
70885bd
minor changes
fabOnReact May 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@ private Layout measureSpannedText(Spannable text, float width, YogaMeasureMode w
Layout layout;
BoringLayout.Metrics boring = BoringLayout.isBoring(text, textPaint);
float desiredWidth = boring == null ? Layout.getDesiredWidth(text, textPaint) : Float.NaN;
// StaticLayout#getLineWidth does not work with single-line text.
boolean overrideTextBreakStrategySingleLine =
boring == null
? false
: mNumberOfLines == 1 && !mAdjustsFontSizeToFit && boring.width > width;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about

Suggested change
// StaticLayout#getLineWidth does not work with single-line text.
boolean overrideTextBreakStrategySingleLine =
boring == null
? false
: mNumberOfLines == 1 && !mAdjustsFontSizeToFit && boring.width > width;
// StaticLayout#getLineWidth does not work with single-line text.
boolean overrideTextBreakStrategySingleLine =
boring != null && mNumberOfLines == 1 && !mAdjustsFontSizeToFit && boring.width > width;

and we avoid the ternary?


// technically, width should never be negative, but there is currently a bug in
boolean unconstrainedWidth = widthMode == YogaMeasureMode.UNDEFINED || width < 0;
Expand Down Expand Up @@ -237,9 +242,9 @@ private Layout measureSpannedText(Spannable text, float width, YogaMeasureMode w
}
layout = builder.build();

} else if (boring != null && (unconstrainedWidth || boring.width <= width)) {
// Is used for single-line, boring text when the width is either unknown or bigger
// than the width of the text.
} else if (boring != null
&& (unconstrainedWidth || boring.width <= width || overrideTextBreakStrategySingleLine)) {
// Is used for single-line, boring text when adjustsFontSizeToFit is disabled.
layout =
BoringLayout.make(
text,
Expand Down
Loading