[TextServer] Prevent duplicate line breaks on virtual spaces when line width is significantly smaller than character width.
This commit is contained in:
parent
d984ad64d4
commit
8a4a883854
|
@ -714,6 +714,7 @@ PackedInt32Array TextServer::shaped_text_get_line_breaks_adv(const RID &p_shaped
|
||||||
|
|
||||||
real_t width = 0.f;
|
real_t width = 0.f;
|
||||||
int line_start = MAX(p_start, range.x);
|
int line_start = MAX(p_start, range.x);
|
||||||
|
int last_end = line_start;
|
||||||
int prev_safe_break = 0;
|
int prev_safe_break = 0;
|
||||||
int last_safe_break = -1;
|
int last_safe_break = -1;
|
||||||
int word_count = 0;
|
int word_count = 0;
|
||||||
|
@ -739,12 +740,18 @@ PackedInt32Array TextServer::shaped_text_get_line_breaks_adv(const RID &p_shaped
|
||||||
while ((start_pos < end_pos) && ((l_gl[end_pos].flags & GRAPHEME_IS_SPACE) == GRAPHEME_IS_SPACE || (l_gl[end_pos].flags & GRAPHEME_IS_BREAK_HARD) == GRAPHEME_IS_BREAK_HARD || (l_gl[end_pos].flags & GRAPHEME_IS_BREAK_SOFT) == GRAPHEME_IS_BREAK_SOFT)) {
|
while ((start_pos < end_pos) && ((l_gl[end_pos].flags & GRAPHEME_IS_SPACE) == GRAPHEME_IS_SPACE || (l_gl[end_pos].flags & GRAPHEME_IS_BREAK_HARD) == GRAPHEME_IS_BREAK_HARD || (l_gl[end_pos].flags & GRAPHEME_IS_BREAK_SOFT) == GRAPHEME_IS_BREAK_SOFT)) {
|
||||||
end_pos -= l_gl[end_pos].count;
|
end_pos -= l_gl[end_pos].count;
|
||||||
}
|
}
|
||||||
|
if (last_end <= l_gl[start_pos].start) {
|
||||||
lines.push_back(l_gl[start_pos].start);
|
lines.push_back(l_gl[start_pos].start);
|
||||||
lines.push_back(l_gl[end_pos].end);
|
lines.push_back(l_gl[end_pos].end);
|
||||||
|
last_end = l_gl[end_pos].end;
|
||||||
|
}
|
||||||
trim_next = true;
|
trim_next = true;
|
||||||
} else {
|
} else {
|
||||||
|
if (last_end <= line_start) {
|
||||||
lines.push_back(line_start);
|
lines.push_back(line_start);
|
||||||
lines.push_back(l_gl[last_safe_break].end);
|
lines.push_back(l_gl[last_safe_break].end);
|
||||||
|
last_end = l_gl[last_safe_break].end;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
line_start = l_gl[last_safe_break].end;
|
line_start = l_gl[last_safe_break].end;
|
||||||
prev_safe_break = last_safe_break + 1;
|
prev_safe_break = last_safe_break + 1;
|
||||||
|
@ -772,12 +779,18 @@ PackedInt32Array TextServer::shaped_text_get_line_breaks_adv(const RID &p_shaped
|
||||||
while ((start_pos < end_pos) && ((l_gl[end_pos].flags & GRAPHEME_IS_SPACE) == GRAPHEME_IS_SPACE || (l_gl[end_pos].flags & GRAPHEME_IS_BREAK_HARD) == GRAPHEME_IS_BREAK_HARD || (l_gl[end_pos].flags & GRAPHEME_IS_BREAK_SOFT) == GRAPHEME_IS_BREAK_SOFT)) {
|
while ((start_pos < end_pos) && ((l_gl[end_pos].flags & GRAPHEME_IS_SPACE) == GRAPHEME_IS_SPACE || (l_gl[end_pos].flags & GRAPHEME_IS_BREAK_HARD) == GRAPHEME_IS_BREAK_HARD || (l_gl[end_pos].flags & GRAPHEME_IS_BREAK_SOFT) == GRAPHEME_IS_BREAK_SOFT)) {
|
||||||
end_pos -= l_gl[end_pos].count;
|
end_pos -= l_gl[end_pos].count;
|
||||||
}
|
}
|
||||||
|
if (last_end <= l_gl[start_pos].start) {
|
||||||
lines.push_back(l_gl[start_pos].start);
|
lines.push_back(l_gl[start_pos].start);
|
||||||
lines.push_back(l_gl[end_pos].end);
|
lines.push_back(l_gl[end_pos].end);
|
||||||
|
last_end = l_gl[end_pos].end;
|
||||||
|
}
|
||||||
trim_next = false;
|
trim_next = false;
|
||||||
} else {
|
} else {
|
||||||
|
if (last_end <= line_start) {
|
||||||
lines.push_back(line_start);
|
lines.push_back(line_start);
|
||||||
lines.push_back(l_gl[i].end);
|
lines.push_back(l_gl[i].end);
|
||||||
|
last_end = l_gl[i].end;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
line_start = l_gl[i].end;
|
line_start = l_gl[i].end;
|
||||||
prev_safe_break = i + 1;
|
prev_safe_break = i + 1;
|
||||||
|
@ -833,6 +846,7 @@ PackedInt32Array TextServer::shaped_text_get_line_breaks(const RID &p_shaped, do
|
||||||
|
|
||||||
double width = 0.f;
|
double width = 0.f;
|
||||||
int line_start = MAX(p_start, range.x);
|
int line_start = MAX(p_start, range.x);
|
||||||
|
int last_end = line_start;
|
||||||
int prev_safe_break = 0;
|
int prev_safe_break = 0;
|
||||||
int last_safe_break = -1;
|
int last_safe_break = -1;
|
||||||
int word_count = 0;
|
int word_count = 0;
|
||||||
|
@ -857,12 +871,18 @@ PackedInt32Array TextServer::shaped_text_get_line_breaks(const RID &p_shaped, do
|
||||||
while ((start_pos < end_pos) && ((l_gl[end_pos].flags & GRAPHEME_IS_SPACE) == GRAPHEME_IS_SPACE || (l_gl[end_pos].flags & GRAPHEME_IS_BREAK_HARD) == GRAPHEME_IS_BREAK_HARD || (l_gl[end_pos].flags & GRAPHEME_IS_BREAK_SOFT) == GRAPHEME_IS_BREAK_SOFT)) {
|
while ((start_pos < end_pos) && ((l_gl[end_pos].flags & GRAPHEME_IS_SPACE) == GRAPHEME_IS_SPACE || (l_gl[end_pos].flags & GRAPHEME_IS_BREAK_HARD) == GRAPHEME_IS_BREAK_HARD || (l_gl[end_pos].flags & GRAPHEME_IS_BREAK_SOFT) == GRAPHEME_IS_BREAK_SOFT)) {
|
||||||
end_pos -= l_gl[end_pos].count;
|
end_pos -= l_gl[end_pos].count;
|
||||||
}
|
}
|
||||||
|
if (last_end <= l_gl[start_pos].start) {
|
||||||
lines.push_back(l_gl[start_pos].start);
|
lines.push_back(l_gl[start_pos].start);
|
||||||
lines.push_back(l_gl[end_pos].end);
|
lines.push_back(l_gl[end_pos].end);
|
||||||
|
last_end = l_gl[end_pos].end;
|
||||||
|
}
|
||||||
trim_next = true;
|
trim_next = true;
|
||||||
} else {
|
} else {
|
||||||
|
if (last_end <= line_start) {
|
||||||
lines.push_back(line_start);
|
lines.push_back(line_start);
|
||||||
lines.push_back(l_gl[last_safe_break].end);
|
lines.push_back(l_gl[last_safe_break].end);
|
||||||
|
last_end = l_gl[last_safe_break].end;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
line_start = l_gl[last_safe_break].end;
|
line_start = l_gl[last_safe_break].end;
|
||||||
prev_safe_break = last_safe_break + 1;
|
prev_safe_break = last_safe_break + 1;
|
||||||
|
@ -884,11 +904,17 @@ PackedInt32Array TextServer::shaped_text_get_line_breaks(const RID &p_shaped, do
|
||||||
end_pos -= l_gl[end_pos].count;
|
end_pos -= l_gl[end_pos].count;
|
||||||
}
|
}
|
||||||
trim_next = false;
|
trim_next = false;
|
||||||
|
if (last_end <= l_gl[start_pos].start) {
|
||||||
lines.push_back(l_gl[start_pos].start);
|
lines.push_back(l_gl[start_pos].start);
|
||||||
lines.push_back(l_gl[end_pos].end);
|
lines.push_back(l_gl[end_pos].end);
|
||||||
|
last_end = l_gl[end_pos].end;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (last_end <= line_start) {
|
||||||
lines.push_back(line_start);
|
lines.push_back(line_start);
|
||||||
lines.push_back(l_gl[i].end);
|
lines.push_back(l_gl[i].end);
|
||||||
|
last_end = l_gl[i].end;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
line_start = l_gl[i].end;
|
line_start = l_gl[i].end;
|
||||||
prev_safe_break = i + 1;
|
prev_safe_break = i + 1;
|
||||||
|
|
Loading…
Reference in New Issue