From: Stefan Schimanski Date: Thu, 7 Jun 2007 20:40:01 +0000 (+0000) Subject: * cursor_get_font.patch: the Cursor::getFont is responsible for the X-Git-Tag: 1.6.10~9449 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=27bc728f148c4936587ce0fbd0380f0693ff89c4;p=lyx.git * cursor_get_font.patch: the Cursor::getFont is responsible for the cursor size. It should fit to the setCurrentFont function because the cursor tells the user which font will be used when typing characters. Especially on RTL/LTR boundaries it should fit because it is essential for the user to see which writing direction is active. This patch implements a simplified version of setCurrentFont's logic to archive this. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18707 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/Cursor.cpp b/src/Cursor.cpp index d34f348d73..bfb2338b0b 100644 --- a/src/Cursor.cpp +++ b/src/Cursor.cpp @@ -1438,18 +1438,36 @@ void Cursor::noUpdate() Font Cursor::getFont() const { + // The logic here should more or less match to the Text::setCurrentFont + // logic, i.e. the cursor height should give a hint what will happen + // if a character is entered. + // HACK. far from being perfect... - int s = 0; // go up until first non-0 text is hit // (innermost text is 0 in mathed) + int s = 0; for (s = depth() - 1; s >= 0; --s) if (operator[](s).text()) break; CursorSlice const & sl = operator[](s); Text const & text = *sl.text(); - Font font = text.getPar(sl.pit()).getFont( - bv().buffer()->params(), - sl.pos(), + Paragraph const & par = text.getPar(sl.pit()); + + // on boundary, so we are really at the character before + pos_type pos = sl.pos(); + if (pos > 0 && boundary()) + --pos; + + // on space? Take the font before (only for RTL boundary stay) + if (pos > 0) { + if (pos == sl.lastpos() + || (par.isSeparator(pos) && + !text.isRTLBoundary(buffer(), par, pos))) + --pos; + } + + // get font at the position + Font font = par.getFont(bv().buffer()->params(), pos, outerFont(sl.pit(), text.paragraphs())); return font;