diff --git a/src/FontList.cpp b/src/FontList.cpp index a9e9b79011..5906cb4a36 100644 --- a/src/FontList.cpp +++ b/src/FontList.cpp @@ -211,4 +211,20 @@ Font_size FontList::highestInRange return maxsize; } + +bool FontList::hasChangeInRange(pos_type pos, int len) const +{ + // FIXME: can't we use fontIterator(pos) instead? + const_iterator cit = list_.begin(); + const_iterator end = list_.end(); + for (; cit != end; ++cit) { + if (cit->pos() >= pos) + break; + } + if (cit != end && pos + len - 1 > cit->pos()) + return false; + + return true; +} + } // namespace lyx diff --git a/src/FontList.h b/src/FontList.h index 57d6d72950..e99c4a9fa5 100644 --- a/src/FontList.h +++ b/src/FontList.h @@ -103,6 +103,12 @@ public: Font_size def_size ) const; + /// is there a font change in middle of the word? + bool hasChangeInRange( + pos_type pos, ///< position in the paragraph. + int len ///< length of the range to check. + ) const; + private: /// List list_; diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index ce0466f017..a324d80989 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -600,17 +600,7 @@ bool Paragraph::Private::isTextAt(string const & str, pos_type pos) const return false; } - // is there a font change in middle of the word? - FontList::const_iterator cit = fontlist_.begin(); - FontList::const_iterator end = fontlist_.end(); - for (; cit != end; ++cit) { - if (cit->pos() >= pos) - break; - } - if (cit != end && pos + len - 1 > cit->pos()) - return false; - - return true; + return fontlist_.hasChangeInRange(pos, len); }