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
Show file tree
Hide file tree
Changes from all 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 @@ -42,8 +42,14 @@ public static WritableArray getFontMetrics(
X_HEIGHT_MEASUREMENT_TEXT, 0, X_HEIGHT_MEASUREMENT_TEXT.length(), xHeightBounds);
double xHeight = xHeightBounds.height() / AMPLIFICATION_FACTOR / dm.density;
for (int i = 0; i < layout.getLineCount(); i++) {
boolean endsWithNewLine = text.length() > 0 && text.charAt(layout.getLineEnd(i) - 1) == '\n';
float lineWidth = endsWithNewLine ? layout.getLineMax(i) : layout.getLineWidth(i);
float lineWidth;
if (layout.getLineCount() == 1) {
lineWidth = layout.getEllipsizedWidth();
} else {
boolean endsWithNewLine =
text.length() > 0 && text.charAt(layout.getLineEnd(i) - 1) == '\n';
lineWidth = endsWithNewLine ? layout.getLineMax(i) : layout.getLineWidth(i);
}
Rect bounds = new Rect();
layout.getLineBounds(i, bounds);
WritableMap line = Arguments.createMap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,17 @@ public long measure(
if (widthMode == YogaMeasureMode.EXACTLY) {
layoutWidth = width;
} else {
for (int lineIndex = 0; lineIndex < lineCount; lineIndex++) {
boolean endsWithNewLine =
text.length() > 0 && text.charAt(layout.getLineEnd(lineIndex) - 1) == '\n';
float lineWidth =
endsWithNewLine ? layout.getLineMax(lineIndex) : layout.getLineWidth(lineIndex);
if (lineWidth > layoutWidth) {
layoutWidth = lineWidth;
if (mNumberOfLines == 1) {
layoutWidth = (int) layout.getEllipsizedWidth();
} else {
for (int lineIndex = 0; lineIndex < lineCount; lineIndex++) {
boolean endsWithNewLine =
text.length() > 0 && text.charAt(layout.getLineEnd(lineIndex) - 1) == '\n';
float lineWidth =
endsWithNewLine ? layout.getLineMax(lineIndex) : layout.getLineWidth(lineIndex);
if (lineWidth > layoutWidth) {
layoutWidth = lineWidth;
}
}
}
if (widthMode == YogaMeasureMode.AT_MOST && layoutWidth > width) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -601,13 +601,17 @@ public static long measureText(
if (widthYogaMeasureMode == YogaMeasureMode.EXACTLY) {
calculatedWidth = width;
} else {
for (int lineIndex = 0; lineIndex < calculatedLineCount; lineIndex++) {
boolean endsWithNewLine =
text.length() > 0 && text.charAt(layout.getLineEnd(lineIndex) - 1) == '\n';
float lineWidth =
endsWithNewLine ? layout.getLineMax(lineIndex) : layout.getLineWidth(lineIndex);
if (lineWidth > calculatedWidth) {
calculatedWidth = lineWidth;
if (maximumNumberOfLines == 1) {
calculatedWidth = (int) layout.getEllipsizedWidth();
} else {
for (int lineIndex = 0; lineIndex < calculatedLineCount; lineIndex++) {
boolean endsWithNewLine =
text.length() > 0 && text.charAt(layout.getLineEnd(lineIndex) - 1) == '\n';
float lineWidth =
endsWithNewLine ? layout.getLineMax(lineIndex) : layout.getLineWidth(lineIndex);
if (lineWidth > calculatedWidth) {
calculatedWidth = lineWidth;
}
}
}
if (widthYogaMeasureMode == YogaMeasureMode.AT_MOST && calculatedWidth > width) {
Expand Down Expand Up @@ -660,14 +664,18 @@ public static long measureText(
// the last offset in the layout will result in an endless loop. Work around
// this bug by avoiding getPrimaryHorizontal in that case.
if (start == text.length() - 1) {
boolean endsWithNewLine =
text.length() > 0 && text.charAt(layout.getLineEnd(line) - 1) == '\n';
float lineWidth = endsWithNewLine ? layout.getLineMax(line) : layout.getLineWidth(line);
float lineWidth;
if (maximumNumberOfLines == 1) {
lineWidth = layout.getEllipsizedWidth();
} else {
boolean endsWithNewLine =
text.length() > 0 && text.charAt(layout.getLineEnd(line) - 1) == '\n';
lineWidth = endsWithNewLine ? layout.getLineMax(line) : layout.getLineWidth(line);
}
placeholderLeftPosition =
isRtlParagraph
// Equivalent to `layout.getLineLeft(line)` but `getLineLeft` returns
// incorrect
// values when the paragraph is RTL and `setSingleLine(true)`.
// incorrect values when the paragraph is RTL and `setSingleLine(true)`.
? calculatedWidth - lineWidth
: layout.getLineRight(line) - placeholderWidth;
} else {
Expand Down
Loading