* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
- * \author Lars Gullik Bjønnes
+ * \author Lars Gullik Bjønnes
* \author Jean-Marc Lasgouttes
* \author Angus Leeming
- * \author André Pönitz
+ * \author André Pönitz
* \author Dekel Tsur
*
* Full author contact details are available in file CREDITS.
#include "Font.h"
#include "BufferParams.h" // stateText
-#include "Color.h"
-#include "debug.h"
+#include "ColorSet.h"
#include "Encoding.h"
-#include "gettext.h"
#include "Language.h"
#include "LaTeXFeatures.h"
#include "Lexer.h"
#include "output_latex.h"
#include "OutputParams.h"
+#include "support/lassert.h"
#include "support/convert.h"
+#include "support/debug.h"
+#include "support/gettext.h"
#include "support/lstrings.h"
-using std::endl;
-using std::string;
-using std::ostream;
-using std::ostringstream;
-using std::istringstream;
-using std::pair;
-
-#ifndef CXX_GLOBAL_CSTD
-using std::strlen;
-#endif
+#include <cstring>
+using namespace std;
+using namespace lyx::support;
namespace lyx {
-using support::ascii_lowercase;
-using support::bformat;
-using support::rtrim;
-using support::subst;
-
//
// Names for the GUI
//
setLanguage(default_language);
else
setLanguage(document_language);
+ else if (newfont.language() == reset_language)
+ setLanguage(document_language);
else if (newfont.language() != ignore_language)
setLanguage(newfont.language());
}
// Read a font definition from given file in lyx format
// Used for layouts
-FontInfo lyxRead(Lexer & lex)
+FontInfo lyxRead(Lexer & lex, FontInfo const & fi)
{
- FontInfo f;
+ FontInfo f = fi;
bool error = false;
bool finished = false;
while (!finished && lex.isOK() && !error) {
} else if (ttok == "noun") {
f.setNoun(FONT_ON);
} else {
- lex.printError("Illegal misc type `$$Token'");
+ lex.printError("Illegal misc type");
}
} else if (tok == "color") {
lex.next();
string const ttok = lex.getString();
setLyXColor(ttok, f);
} else {
- lex.printError("Unknown tag `$$Token'");
+ lex.printError("Unknown tag");
error = true;
}
}
if (language()->encoding()->package() == Encoding::CJK) {
pair<bool, int> const c = switchEncoding(os, bparams,
- runparams.moving_arg, *(runparams.encoding),
- *(language()->encoding()));
+ runparams, *(language()->encoding()));
if (c.first) {
open_encoding_ = true;
count += c.second;
if (open_encoding_) {
// We need to close the encoding even if it does not change
// to do correct environment nesting
- Encoding const * const ascii = encodings.getFromLyXName("ascii");
+ Encoding const * const ascii = encodings.fromLyXName("ascii");
pair<bool, int> const c = switchEncoding(os, bparams,
- runparams.moving_arg, *(runparams.encoding),
- *ascii);
- BOOST_ASSERT(c.first);
+ runparams, *ascii);
+ LASSERT(c.first, /**/);
count += c.second;
runparams.encoding = ascii;
open_encoding_ = false;
}
-std::string Font::toString(bool const toggle) const
+string Font::toString(bool const toggle) const
{
- string lang = "ignore";
- if (language())
- lang = language()->lang();
+ string const lang = (language() == reset_language)
+ ? "reset" : language()->lang();
ostringstream os;
- os << "font: " << '\n'
- << "family " << bits_.family() << '\n'
+ os << "family " << bits_.family() << '\n'
<< "series " << bits_.series() << '\n'
<< "shape " << bits_.shape() << '\n'
<< "size " << bits_.size() << '\n'
bool Font::fromString(string const & data, bool & toggle)
{
istringstream is(data);
- Lexer lex(0,0);
+ Lexer lex;
lex.setStream(is);
int nset = 0;
} else if (token == "language") {
string const next = lex.getString();
- if (next == "ignore")
- setLanguage(ignore_language);
- else
- setLanguage(languages.getLanguage(next));
+ setLanguage(languages.getLanguage(next));
} else if (token == "toggleall") {
toggle = lex.getBool();
Language const * doc_language = bparams.language;
if (bits_.noun() == FONT_ON) {
- LYXERR(Debug::LATEX) << "font.noun: "
- << bits_.noun()
- << endl;
+ LYXERR(Debug::LATEX, "font.noun: " << bits_.noun());
features.require("noun");
- LYXERR(Debug::LATEX) << "Noun enabled. Font: "
- << to_utf8(stateText(0))
- << endl;
+ LYXERR(Debug::LATEX, "Noun enabled. Font: " << to_utf8(stateText(0)));
}
switch (bits_.color()) {
case Color_none:
// 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:
+ case Color_notelabel:
break;
default:
features.require("color");
- LYXERR(Debug::LATEX) << "Color enabled. Font: "
- << to_utf8(stateText(0))
- << endl;
+ LYXERR(Debug::LATEX, "Color enabled. Font: " << to_utf8(stateText(0)));
}
// FIXME: Do something for background and soul package?
lang_ != latex_language)
{
features.useLanguage(lang_);
- LYXERR(Debug::LATEX) << "Found language "
- << lang_->lang() << endl;
+ LYXERR(Debug::LATEX, "Found language " << lang_->lang());
}
}
}
-ostream & operator<<(std::ostream & os, FontInfo const & f)
+ostream & operator<<(ostream & os, FontInfo const & f)
{
return os << "font:"
<< " family " << f.family()
}
-std::ostream & operator<<(std::ostream & os, Font const & font)
+ostream & operator<<(ostream & os, Font const & font)
{
return os << font.bits_
<< " lang: " << (font.lang_ ? font.lang_->lang() : 0);