Take in account end of paragraph marker for inset width

When an inset wants to use the whole available width, it is necessary
to take into account that some of this width may already be taken by
the end-of-paragraph (pilcrow) marker.

Fixes bug #10537.

(cherry picked from commit 91f3b21e42)
This commit is contained in:
Jean-Marc Lasgouttes 2017-05-24 14:05:06 +02:00
parent f3fcf18e96
commit 413de12adf
2 changed files with 18 additions and 5 deletions

View File

@ -421,10 +421,21 @@ bool TextMetrics::redoParagraph(pit_type const pit)
parPos.pos()++; parPos.pos()++;
} }
// If there is an end of paragraph marker, its size should be
// substracted to the available width. The logic here is
// almost the same as in breakRow, remember keep them in sync.
int eop = 0;
if (lyxrc.paragraph_markers && ii->pos + 1 == par.size()
&& size_type(pit + 1) < text_->paragraphs().size()) {
Font f(text_->layoutFont(pit));
// ¶ U+00B6 PILCROW SIGN
eop = theFontMetrics(f).width(char_type(0x00B6));
}
// do the metric calculation // do the metric calculation
Dimension dim; Dimension dim;
int const w = max_width_ - leftMargin(max_width_, pit, ii->pos) int const w = max_width_ - leftMargin(max_width_, pit, ii->pos)
- right_margin; - right_margin - eop;
Font const & font = ii->inset->inheritFont() ? Font const & font = ii->inset->inheritFont() ?
displayFont(pit, ii->pos) : bufferfont; displayFont(pit, ii->pos) : bufferfont;
MacroContext mc(&buffer, parPos); MacroContext mc(&buffer, parPos);
@ -807,8 +818,6 @@ void TextMetrics::breakRow(Row & row, int const right_margin, pit_type const pit
// the width available for the row. // the width available for the row.
int const width = max_width_ - row.right_margin; int const width = max_width_ - row.right_margin;
ParagraphList const & pars = text_->paragraphs();
#if 0 #if 0
//FIXME: As long as leftMargin() is not correctly implemented for //FIXME: As long as leftMargin() is not correctly implemented for
// MARGIN_RIGHT_ADDRESS_BOX, we should also not do this here. // MARGIN_RIGHT_ADDRESS_BOX, we should also not do this here.
@ -916,7 +925,9 @@ void TextMetrics::breakRow(Row & row, int const right_margin, pit_type const pit
row.finalizeLast(); row.finalizeLast();
row.endpos(i); row.endpos(i);
// End of paragraph marker // End of paragraph marker. The logic here is almost the
// same as in redoParagraph, remember keep them in sync.
ParagraphList const & pars = text_->paragraphs();
if (lyxrc.paragraph_markers && !need_new_row if (lyxrc.paragraph_markers && !need_new_row
&& i == end && size_type(pit + 1) < pars.size()) { && i == end && size_type(pit + 1) < pars.size()) {
// add a virtual element for the end-of-paragraph // add a virtual element for the end-of-paragraph

View File

@ -48,13 +48,15 @@ What's new
- Remove duplicate entries from the Symbols dialog (bug 10644). - Remove duplicate entries from the Symbols dialog (bug 10644).
- Always shows the float type in the float inset label (bug 10618). - Always show the float type in the float inset label (bug 10618).
- Show correct color name for green in the status bar (bug 10656). - Show correct color name for green in the status bar (bug 10656).
- fixes to cursor positionning on mouse click for right-to-left text - fixes to cursor positionning on mouse click for right-to-left text
(bug 10569). (bug 10569).
- Fix metricsof full-width insets when paragraph endings are shown (bug #10537).
* INTERNALS * INTERNALS