diff --git a/src/Cursor.cpp b/src/Cursor.cpp index 2b301257f6..38ec3e4ebe 100644 --- a/src/Cursor.cpp +++ b/src/Cursor.cpp @@ -1413,13 +1413,7 @@ Encoding const * Cursor::getEncoding() const { if (empty()) return 0; - int s = 0; - // go up until first non-0 text is hit - // (innermost text is 0 in mathed) - for (s = depth() - 1; s >= 0; --s) - if (operator[](s).text()) - break; - CursorSlice const & sl = operator[](s); + CursorSlice const & sl = innerTextSlice(); Text const & text = *sl.text(); Font font = text.getPar(sl.pit()).getFont( bv().buffer().params(), sl.pos(), outerFont(sl.pit(), text.paragraphs())); @@ -1458,13 +1452,8 @@ Font Cursor::getFont() const // if a character is entered. // HACK. far from being perfect... - // 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); + + CursorSlice const & sl = innerTextSlice(); Text const & text = *sl.text(); Paragraph const & par = text.getPar(sl.pit());