]> git.lyx.org Git - lyx.git/blobdiff - src/Font.cpp
Fix layout bug. Pasting text into a cell tried to set Standard layout, because
[lyx.git] / src / Font.cpp
index a1492db03233f6909792ca7dd318ec375d7a279d..76a716da3ac66beff9bf6d24d92fae6b3acf3665 100644 (file)
 #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"
 
+#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
 //
@@ -147,6 +146,8 @@ void Font::update(Font const & newfont,
                        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());
 }
@@ -339,14 +340,14 @@ FontInfo lyxRead(Lexer & lex, FontInfo const & fi)
                        } 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;
                }
        }
@@ -454,8 +455,7 @@ int Font::latexWriteStartChanges(odocstream & os, BufferParams const & bparams,
 
        if (language()->encoding()->package() == Encoding::CJK) {
                pair<bool, int> const c = switchEncoding(os, bparams,
-                               runparams, *(runparams.encoding),
-                               *(language()->encoding()));
+                               runparams, *(language()->encoding()));
                if (c.first) {
                        open_encoding_ = true;
                        count += c.second;
@@ -623,11 +623,10 @@ int Font::latexWriteEndChanges(odocstream & os, BufferParams const & bparams,
        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, *(runparams.encoding),
-                               *ascii);
-               BOOST_ASSERT(c.first);
+                               runparams, *ascii);
+               LASSERT(c.first, /**/);
                count += c.second;
                runparams.encoding = ascii;
                open_encoding_ = false;
@@ -643,11 +642,10 @@ int Font::latexWriteEndChanges(odocstream & os, BufferParams const & bparams,
 }
 
 
-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 << "family " << bits_.family() << '\n'
@@ -668,7 +666,7 @@ std::string Font::toString(bool const toggle) const
 bool Font::fromString(string const & data, bool & toggle)
 {
        istringstream is(data);
-       Lexer lex(0,0);
+       Lexer lex;
        lex.setStream(is);
 
        int nset = 0;
@@ -723,10 +721,7 @@ bool Font::fromString(string const & data, bool & toggle)
 
                } 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();
@@ -759,7 +754,7 @@ void Font::validate(LaTeXFeatures & features) const
                        // 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");
@@ -784,7 +779,7 @@ ostream & operator<<(ostream & os, FontState fms)
 }
 
 
-ostream & operator<<(std::ostream & os, FontInfo const & f)
+ostream & operator<<(ostream & os, FontInfo const & f)
 {
        return os << "font:"
                << " family " << f.family()
@@ -801,7 +796,7 @@ ostream & operator<<(std::ostream & os, FontInfo const & f)
 }
 
 
-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);