+ return true;
+ }
+ return false;
+}
+
+
+bool notifyCursorLeaves(DocIterator const & old, Cursor & cur)
+{
+ // find inset in common
+ size_type i;
+ for (i = 0; i < old.depth() && i < cur.depth(); ++i) {
+ if (&old.inset() != &cur.inset())
+ break;
+ }
+
+ // notify everything on top of the common part in old cursor,
+ // but stop if the inset claims the cursor to be invalid now
+ for (; i < old.depth(); ++i) {
+ if (old[i].inset().notifyCursorLeaves(cur))
+ return true;
+ }
+
+ return false;
+}
+
+
+void Cursor::setCurrentFont()
+{
+ CursorSlice const & cs = innerTextSlice();
+ Paragraph const & par = cs.paragraph();
+ pos_type cpit = cs.pit();
+ pos_type cpos = cs.pos();
+ Text const & ctext = *cs.text();
+ TextMetrics const & tm = bv().textMetrics(&ctext);
+
+ // are we behind previous char in fact? -> go to that char
+ if (cpos > 0 && boundary())
+ --cpos;
+
+ // find position to take the font from
+ if (cpos != 0) {
+ // paragraph end? -> font of last char
+ if (cpos == lastpos())
+ --cpos;
+ // on space? -> look at the words in front of space
+ else if (cpos > 0 && par.isSeparator(cpos)) {
+ // abc| def -> font of c
+ // abc |[WERBEH], i.e. boundary==true -> font of c
+ // abc [WERBEH]| def, font of the space
+ if (!tm.isRTLBoundary(cpit, cpos))
+ --cpos;
+ }
+ }
+
+ // get font
+ BufferParams const & bufparams = buffer().params();
+ current_font = par.getFontSettings(bufparams, cpos);
+ real_current_font = tm.getDisplayFont(cpit, cpos);
+
+ // special case for paragraph end
+ if (cs.pos() == lastpos()
+ && tm.isRTLBoundary(cpit, cs.pos())
+ && !boundary()) {
+ Language const * lang = par.getParLanguage(bufparams);
+ current_font.setLanguage(lang);
+ current_font.fontInfo().setNumber(FONT_OFF);
+ real_current_font.setLanguage(lang);
+ real_current_font.fontInfo().setNumber(FONT_OFF);