}
-bool Paragraph::Pimpl::isTextAt(BufferParams const & bp,
- string const & str, pos_type pos)
+bool Paragraph::Pimpl::isTextAt(string const & str, pos_type pos)
{
- LyXFont const & font = owner_->getFont(bp, pos);
+ pos_type const len = str.length();
+
+ // is the paragraph large enough?
+ if (pos + len > size())
+ return false;
+ // does the wanted text start at point?
for (string::size_type i = 0; i < str.length(); ++i) {
- if (pos + static_cast<pos_type>(i) >= size())
- return false;
- if (str[i] != getChar(pos + i))
- return false;
- if (owner_->getFont(bp, pos + i) != font)
+ if (str[i] != text[pos + i])
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;
}
size_t pnr = 0;
for (; pnr < phrases_nr; ++pnr) {
- if (isTextAt(bparams, special_phrases[pnr][0], i)) {
+ if (isTextAt(special_phrases[pnr][0], i)) {
os << special_phrases[pnr][1];
i += special_phrases[pnr][0].length() - 1;
column += special_phrases[pnr][1].length() - 1;