mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-28 23:15:19 +00:00
Fix wrong splitting of text row
The code that tries to decide whether it is worth splitting a given
text row element had a shortcoming: it did not take into account the
left margin of the new row that would be created.
The problem is that this left margin is not the same as the left
margin of the current row, because there can be for example
indentation effects.
To fix this problem, we pass the amount of available space on the
next row as a parameter of Row::shortenIfNeeded.
Note that there is no need to care about RtL row elements at this
point, since the bidi algorithm will be applied to the row
subsequently.
(cherry picked from commit 8491962c6b
)
This commit is contained in:
parent
ddac5a7f59
commit
b0673bd1fa
@ -110,7 +110,6 @@ pos_type Row::Element::x2pos(int &x) const
|
||||
}
|
||||
//lyxerr << "=> p=" << pos + i << " x=" << x << endl;
|
||||
return pos + i;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -413,7 +412,7 @@ void Row::pop_back()
|
||||
}
|
||||
|
||||
|
||||
bool Row::shortenIfNeeded(pos_type const keep, int const w)
|
||||
bool Row::shortenIfNeeded(pos_type const keep, int const w, int const next_width)
|
||||
{
|
||||
if (empty() || width() <= w)
|
||||
return false;
|
||||
@ -460,7 +459,7 @@ bool Row::shortenIfNeeded(pos_type const keep, int const w)
|
||||
* next row. Thus breaking does not help.
|
||||
*/
|
||||
if (wid_brk + cit_brk->dim.wid < w
|
||||
&& dim_.wid - (wid_brk + brk.dim.wid) >= w) {
|
||||
&& dim_.wid - (wid_brk + brk.dim.wid) >= next_width) {
|
||||
break;
|
||||
}
|
||||
end_ = brk.endpos;
|
||||
|
@ -230,10 +230,11 @@ public:
|
||||
* separator and update endpos if necessary. If all that
|
||||
* remains is a large word, cut it to \param width.
|
||||
* \param body_pos minimum amount of text to keep.
|
||||
* \param width maximum width of the row
|
||||
* \param width maximum width of the row.
|
||||
* \param available width on next row.
|
||||
* \return true if the row has been shortened.
|
||||
*/
|
||||
bool shortenIfNeeded(pos_type const body_pos, int const width);
|
||||
bool shortenIfNeeded(pos_type const body_pos, int const width, int const next_width);
|
||||
|
||||
/**
|
||||
* If last element of the row is a string, compute its width
|
||||
|
@ -933,7 +933,9 @@ void TextMetrics::breakRow(Row & row, int const right_margin, pit_type const pit
|
||||
|
||||
// if the row is too large, try to cut at last separator. In case
|
||||
// of success, reset indication that the row was broken abruptly.
|
||||
if (row.shortenIfNeeded(body_pos, width))
|
||||
int const next_width = max_width_ - leftMargin(max_width_, row.pit(), row.endpos())
|
||||
- rightMargin(row.pit());
|
||||
if (row.shortenIfNeeded(body_pos, width, next_width))
|
||||
row.right_boundary(!row.empty() && row.back().endpos == row.endpos());
|
||||
|
||||
// make sure that the RTL elements are in reverse ordering
|
||||
|
@ -161,6 +161,9 @@ What's new
|
||||
- Fix cursor movement when the document contains high-plane Unicode
|
||||
characters (bug 10443).
|
||||
|
||||
- Fix wrong on-screen text layout where a word would be alone on a
|
||||
line.
|
||||
|
||||
- Fix crash when the document contains Unicode line-breaking characters.
|
||||
|
||||
- Allow using colors supported by xcolor inside mathed (bug 10417).
|
||||
|
Loading…
Reference in New Issue
Block a user