* safe Text::setCurrentFont which does not use Text::bidi and hence

does not depend on paragraph metrics (fixes #3790, #3801, #3809)


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18705 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Stefan Schimanski 2007-06-07 19:55:22 +00:00
parent ff8fcc268a
commit 41e194bf88

View File

@ -11,6 +11,7 @@
* \author John Levon * \author John Levon
* \author André Pönitz * \author André Pönitz
* \author Allan Rae * \author Allan Rae
* \author Stefan Schimanski
* \author Dekel Tsur * \author Dekel Tsur
* \author Jürgen Vigna * \author Jürgen Vigna
* *
@ -760,40 +761,31 @@ void Text::setCurrentFont(Cursor & cur)
pos_type pos = cur.pos(); pos_type pos = cur.pos();
Paragraph & par = cur.paragraph(); Paragraph & par = cur.paragraph();
// ignore empty paragraph // are we behind previous char in fact? -> go to that char
if (par.empty()) if (pos > 0 && cur.boundary())
return;
// if on boundary or at paragraph end, set font of previous char
if ((pos > 0 && cur.boundary()) || pos == cur.lastpos())
--pos; --pos;
// we changed the line and the bidi tables are outdated? // find position to take the font from
if (!bidi.inRange(pos)) if (pos != 0) {
bidi.computeTables(par, cur.buffer(), cur.textRow()); // paragraph end? -> font of last char
// now in range?
if (!bidi.inRange(pos))
return;
if (pos > 0) {
if (pos == cur.lastpos()) if (pos == cur.lastpos())
--pos; --pos;
else // potentional bug... BUG (Lgb) // on space? -> look at the words in front of space
if (par.isSeparator(pos)) { else if (pos > 0 && par.isSeparator(pos)) {
if (pos > cur.textRow().pos() && // abc| def -> font of c
bidi.level(pos) % 2 == // abc |[WERBEH], i.e. boundary==true -> font of c
bidi.level(pos - 1) % 2) // abc [WERBEH]| def, font of the space
if (!isRTLBoundary(cur.buffer(), par, pos))
--pos; --pos;
else if (pos + 1 < cur.lastpos())
++pos;
} }
} }
// get font
BufferParams const & bufparams = cur.buffer().params(); BufferParams const & bufparams = cur.buffer().params();
current_font = par.getFontSettings(bufparams, pos); current_font = par.getFontSettings(bufparams, pos);
real_current_font = getFont(cur.buffer(), par, pos); real_current_font = getFont(cur.buffer(), par, pos);
// special case for paragraph end
if (cur.pos() == cur.lastpos() if (cur.pos() == cur.lastpos()
&& isRTLBoundary(cur.buffer(), par, cur.pos()) && isRTLBoundary(cur.buffer(), par, cur.pos())
&& !cur.boundary()) { && !cur.boundary()) {