X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FTextMetrics.cpp;h=f78594f54dad9860e42a6f2f05aedc13224edb32;hb=bb80bd78f981c888efcc030168bd4e366b0ca6cd;hp=8a62776f39d2bf61758c967a4f6d6df21ef54025;hpb=d833a023f64ea4d9933ab8ff7a49a3369ac1c95b;p=lyx.git diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp index 8a62776f39..f78594f54d 100644 --- a/src/TextMetrics.cpp +++ b/src/TextMetrics.cpp @@ -244,11 +244,9 @@ int TextMetrics::rightMargin(pit_type const pit) const void TextMetrics::applyOuterFont(Font & font) const { - Font lf(font_); - lf.fontInfo().reduce(bv_->buffer().params().getFont().fontInfo()); - lf.fontInfo().realize(font.fontInfo()); - lf.setLanguage(font.language()); - font = lf; + FontInfo lf(font_.fontInfo()); + lf.reduce(bv_->buffer().params().getFont().fontInfo()); + font.fontInfo().realize(lf); } @@ -447,7 +445,7 @@ bool TextMetrics::redoParagraph(pit_type const pit) - right_margin; Font const & font = ii->inset->noFontChange() ? bufferfont : displayFont(pit, ii->pos); - MacroContext mc(buffer, parPos); + MacroContext mc(&buffer, parPos); MetricsInfo mi(bv_, font.fontInfo(), w, mc); ii->inset->metrics(mi, dim); Dimension const old_dim = pm.insetDimension(ii->inset); @@ -1234,6 +1232,12 @@ pos_type TextMetrics::getColumnNearX(pit_type const pit, return 0; } + // if the first character is a separator, we are in RTL + // text. This character will not be painted on screen + // and thus we should not count it and skip to the next. + if (par.isSeparator(bidi.vis2log(vc))) + ++vc; + while (vc < end && tmpx <= x) { c = bidi.vis2log(vc); last_tmpx = tmpx; @@ -1445,8 +1449,8 @@ Row const & TextMetrics::getPitAndRowNearY(int & y, pit_type & pit, if (yy + rit->height() > y) break; - if (assert_in_view && yy + rit->height() != y) { - if (!up) { + if (assert_in_view) { + if (!up && yy + rit->height() > y) { if (rit != pm.rows().begin()) { y = yy; --rit; @@ -1458,11 +1462,11 @@ Row const & TextMetrics::getPitAndRowNearY(int & y, pit_type & pit, --rit; y = yy; } - } else { + } else if (up && yy != y) { if (rit != rlast) { y = yy + rit->height(); ++rit; - } else if (pit != int(par_metrics_.size())) { + } else if (pit < int(text_->paragraphs().size()) - 1) { ++pit; newParMetricsDown(); ParagraphMetrics const & pm2 = par_metrics_[pit]; @@ -1489,8 +1493,8 @@ Inset * TextMetrics::editXY(Cursor & cur, int x, int y, int yy = y; // is modified by getPitAndRowNearY Row const & row = getPitAndRowNearY(yy, pit, assert_in_view, up); - bool bound = false; + bool bound = false; // is modified by getColumnNearX int xx = x; // is modified by getColumnNearX pos_type const pos = row.pos() + getColumnNearX(pit, row, xx, bound); @@ -1512,17 +1516,16 @@ Inset * TextMetrics::editXY(Cursor & cur, int x, int y, } ParagraphList const & pars = text_->paragraphs(); - Inset const * insetBefore = pos ? pars[pit].getInset(pos - 1) : 0; - //Inset * insetBehind = pars[pit].getInset(pos); + Inset const * inset_before = pos ? pars[pit].getInset(pos - 1) : 0; // This should be just before or just behind the // cursor position set above. - LASSERT((pos != 0 && inset == insetBefore) + LASSERT(inset == inset_before || inset == pars[pit].getInset(pos), /**/); // Make sure the cursor points to the position before // this inset. - if (inset == insetBefore) { + if (inset == inset_before) { --cur.pos(); cur.boundary(false); }