Example #1
0
void Font::validate(LaTeXFeatures & features) const
{
	BufferParams const & bparams = features.bufferParams();
	Language const * doc_language = bparams.language;

	if (bits_.noun() == FONT_ON) {
		LYXERR(Debug::LATEX, "font.noun: " << bits_.noun());
		features.require("noun");
		LYXERR(Debug::LATEX, "Noun enabled. Font: " << to_utf8(stateText(0)));
	}
	if (bits_.underbar() == FONT_ON) {
		LYXERR(Debug::LATEX, "font.underline: " << bits_.underbar());
		features.require("ulem");
		LYXERR(Debug::LATEX, "Underline enabled. Font: " << to_utf8(stateText(0)));
	}
	if (bits_.strikeout() == FONT_ON) {
		LYXERR(Debug::LATEX, "font.strikeout: " << bits_.strikeout());
		features.require("ulem");
		LYXERR(Debug::LATEX, "Strikeout enabled. Font: " << to_utf8(stateText(0)));
	}
	if (bits_.uuline() == FONT_ON) {
		LYXERR(Debug::LATEX, "font.uuline: " << bits_.uuline());
		features.require("ulem");
		LYXERR(Debug::LATEX, "Double underline enabled. Font: " << to_utf8(stateText(0)));
	}
	if (bits_.uwave() == FONT_ON) {
		LYXERR(Debug::LATEX, "font.uwave: " << bits_.uwave());
		features.require("ulem");
		LYXERR(Debug::LATEX, "Wavy underline enabled. Font: " << to_utf8(stateText(0)));
	}
	switch (bits_.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_notelabel:
			break;
		default:
			features.require("color");
			LYXERR(Debug::LATEX, "Color enabled. Font: " << to_utf8(stateText(0)));
	}

	// FIXME: Do something for background and soul package?

	if (((features.usePolyglossia() && lang_->polyglossia() != doc_language->polyglossia())
	     || (features.useBabel() && lang_->babel() != doc_language->babel())
	     || (doc_language->encoding()->package() == Encoding::CJK && lang_ != doc_language))
	    && lang_ != ignore_language
	    && lang_ != latex_language)
	{
		features.useLanguage(lang_);
		LYXERR(Debug::LATEX, "Found language " << lang_->lang());
	}
}