#include "FontList.h"
-#include "BufferParams.h"
-#include "debug.h"
-#include "Language.h"
-#include "LaTeXFeatures.h"
-
#include <boost/next_prior.hpp>
#include <algorithm>
iterator beg = list_.begin();
if (it != list_.end() && it->pos() == pos
&& (pos == 0
- || (it != beg && boost::prior(it)->pos() == pos - 1))) {
+ || (it != list_.begin() && boost::prior(it)->pos() == pos - 1))) {
// If it is a multi-character font
// entry, we just make it smaller
// (see update below), otherwise we
// should delete it.
- unsigned int const i = it - beg;
- list_.erase(beg + i);
- it = beg + i;
+ unsigned int const i = it - list_.begin();
+ list_.erase(it);
+ if (i >= list_.size())
+ return;
+ it = list_.begin() + i;
if (i > 0 && i < list_.size() &&
list_[i - 1].font() == list_[i].font()) {
list_.erase(beg + i - 1);
- it = beg + i - 1;
+ it = list_.begin() + i - 1;
}
}
}
+void FontList::setRange(pos_type startpos, pos_type endpos, Font const & font)
+{
+ // FIXME: Optimize!!!
+ for (pos_type pos = startpos; pos != endpos; ++pos)
+ set(pos, font);
+}
+
+
void FontList::set(pos_type pos, Font const & font)
{
// No need to simplify this because it will disappear
void FontList::validate(LaTeXFeatures & features) const
{
- BufferParams const & bparams = features.bufferParams();
- Language const * doc_language = bparams.language;
-
const_iterator fcit = list_.begin();
const_iterator fend = list_.end();
- for (; fcit != fend; ++fcit) {
- if (fcit->font().noun() == Font::ON) {
- LYXERR(Debug::LATEX) << "font.noun: "
- << fcit->font().noun()
- << endl;
- features.require("noun");
- LYXERR(Debug::LATEX) << "Noun enabled. Font: "
- << to_utf8(fcit->font().stateText(0))
- << endl;
- }
- switch (fcit->font().color()) {
- case Color::none:
- case Color::inherit:
- case Color::ignore:
- // probably we should put here all interface colors used for
- // font displaying! For now I just add this ones I know of (Jug)
- case Color::latex:
- case Color::note:
- break;
- default:
- features.require("color");
- LYXERR(Debug::LATEX) << "Color enabled. Font: "
- << to_utf8(fcit->font().stateText(0))
- << endl;
- }
-
- Language const * language = fcit->font().language();
- if (language->babel() != doc_language->babel() &&
- language != ignore_language &&
- language != latex_language)
- {
- features.useLanguage(language);
- LYXERR(Debug::LATEX) << "Found language "
- << language->lang() << endl;
- }
- }
+ for (; fcit != fend; ++fcit)
+ fcit->font().validate(features);
}
} // namespace lyx