* 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
This commit is contained in:
Stefan Schimanski 2007-06-07 20:40:01 +00:00
parent 6daaf5388b
commit 27bc728f14

View File

@ -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;