]> git.lyx.org Git - lyx.git/blobdiff - src/Font.cpp
Fix bug #12772
[lyx.git] / src / Font.cpp
index b70c237db4d14498f798ea42e60c2a2036b9400d..aa8c235f11a407590d5cb59400dfcd64a173f3c2 100644 (file)
@@ -294,7 +294,7 @@ int Font::latexWriteStartChanges(otexstream & os, BufferParams const & bparams,
                        os << "\\textLR{";
                        count += 8;
                // currently the remaining RTL languages are arabic_arabtex and hebrew
-               } else if (isRightToLeft() != prev.isRightToLeft()) {
+               } else if (isRightToLeft() != prev.isRightToLeft() && !runparams.isFullUnicode()) {
                        if (needs_cprotection) {
                                os << "\\cprotect";
                                count += 9;
@@ -336,11 +336,18 @@ int Font::latexWriteStartChanges(otexstream & os, BufferParams const & bparams,
        p.reduce(prev.bits_);
 
        if (f.size() != INHERIT_SIZE) {
-               os << '{';
-               ++count;
-               os << '\\'
-                  << LaTeXSizeSwitchNames[f.size()] << termcmd;
-               count += strlen(LaTeXSizeSwitchNames[f.size()]) + 1;
+               if (!runparams.find_effective()) {
+                       os << '{';
+                       ++count;
+                       os << '\\'
+                          << LaTeXSizeSwitchNames[f.size()] << termcmd;
+                       count += strlen(LaTeXSizeSwitchNames[f.size()]) + 1;
+               }
+               else {
+                       os << '\\'
+                          << LaTeXSizeSwitchNames[f.size()] << '{';
+                       count += strlen(LaTeXSizeSwitchNames[f.size()]) + 2;
+               }
        }
        if (f.family() != INHERIT_FAMILY) {
                if (non_inherit_inset) {
@@ -399,10 +406,6 @@ int Font::latexWriteStartChanges(otexstream & os, BufferParams const & bparams,
                        os << '}';
                        ++count;
                } else if (f.color() != Color_none) {
-                       if (needs_cprotection) {
-                               os << "\\cprotect";
-                               count += 9;
-                       }
                        os << "\\textcolor{"
                           << from_ascii(lcolor.getLaTeXName(f.color()))
                           << "}{";
@@ -432,9 +435,12 @@ int Font::latexWriteStartChanges(otexstream & os, BufferParams const & bparams,
                || language()->lang() == "arabic_arabi")) {
                if (runparams.use_polyglossia) {
                        // LuaTeX/luabidi
-                       os << "\\LR{";
-                       count += 5;
-               } else {
+                       // \LR needs extra grouping
+                       // (possibly a LuaTeX bug)
+                       os << "{\\LR{";
+                       count += 6;
+               } else if (!runparams.isFullUnicode()) {
+                       // not needed with babel/lua|xetex
                        os << "{\\beginL ";
                        count += 9;
                }
@@ -607,9 +613,12 @@ int Font::latexWriteEndChanges(otexstream & os, BufferParams const & bparams,
                || language()->lang() == "arabic_arabi")) {
                if (runparams.use_polyglossia) {
                        // LuaTeX/luabidi
-                       os << "}";
-                       count += 1;
-               } else {
+                       // luabidi's \LR needs extra grouping
+                       // (possibly a LuaTeX bug)
+                       os << "}}";
+                       count += 2;
+               } else if (!runparams.isFullUnicode()) {
+                       // not needed with babel/lua|xetex
                        os << "\\endL}";
                        count += 6;
                }
@@ -635,7 +644,7 @@ int Font::latexWriteEndChanges(otexstream & os, BufferParams const & bparams,
                bool const using_begin_end =
                        runparams.use_polyglossia ||
                                !lyxrc.language_command_end.empty();
-               if (using_begin_end)
+               if (using_begin_end && !languageStackEmpty())
                        popLanguageName();
        }
 
@@ -762,34 +771,34 @@ void Font::validate(LaTeXFeatures & features) const
        Language const * doc_language = bparams.language;
 
        if (bits_.noun() == FONT_ON) {
-               LYXERR(Debug::LATEX, "font.noun: " << bits_.noun());
+               LYXERR(Debug::OUTFILE, "font.noun: " << bits_.noun());
                features.require("noun");
-               LYXERR(Debug::LATEX, "Noun enabled. Font: " << to_utf8(stateText()));
+               LYXERR(Debug::OUTFILE, "Noun enabled. Font: " << to_utf8(stateText()));
        }
        if (bits_.underbar() == FONT_ON) {
-               LYXERR(Debug::LATEX, "font.underline: " << bits_.underbar());
+               LYXERR(Debug::OUTFILE, "font.underline: " << bits_.underbar());
                features.require("ulem");
-               LYXERR(Debug::LATEX, "Underline enabled. Font: " << to_utf8(stateText()));
+               LYXERR(Debug::OUTFILE, "Underline enabled. Font: " << to_utf8(stateText()));
        }
        if (bits_.strikeout() == FONT_ON) {
-               LYXERR(Debug::LATEX, "font.strikeout: " << bits_.strikeout());
+               LYXERR(Debug::OUTFILE, "font.strikeout: " << bits_.strikeout());
                features.require("ulem");
-               LYXERR(Debug::LATEX, "Strike out enabled. Font: " << to_utf8(stateText()));
+               LYXERR(Debug::OUTFILE, "Strike out enabled. Font: " << to_utf8(stateText()));
        }
        if (bits_.xout() == FONT_ON) {
-               LYXERR(Debug::LATEX, "font.xout: " << bits_.xout());
+               LYXERR(Debug::OUTFILE, "font.xout: " << bits_.xout());
                features.require("ulem");
-               LYXERR(Debug::LATEX, "Cross out enabled. Font: " << to_utf8(stateText()));
+               LYXERR(Debug::OUTFILE, "Cross out enabled. Font: " << to_utf8(stateText()));
        }
        if (bits_.uuline() == FONT_ON) {
-               LYXERR(Debug::LATEX, "font.uuline: " << bits_.uuline());
+               LYXERR(Debug::OUTFILE, "font.uuline: " << bits_.uuline());
                features.require("ulem");
-               LYXERR(Debug::LATEX, "Double underline enabled. Font: " << to_utf8(stateText()));
+               LYXERR(Debug::OUTFILE, "Double underline enabled. Font: " << to_utf8(stateText()));
        }
        if (bits_.uwave() == FONT_ON) {
-               LYXERR(Debug::LATEX, "font.uwave: " << bits_.uwave());
+               LYXERR(Debug::OUTFILE, "font.uwave: " << bits_.uwave());
                features.require("ulem");
-               LYXERR(Debug::LATEX, "Wavy underline enabled. Font: " << to_utf8(stateText()));
+               LYXERR(Debug::OUTFILE, "Wavy underline enabled. Font: " << to_utf8(stateText()));
        }
        switch (bits_.color()) {
                case Color_none:
@@ -815,7 +824,7 @@ void Font::validate(LaTeXFeatures & features) const
                        break;
                default:
                        features.require("color");
-                       LYXERR(Debug::LATEX, "Color enabled. Font: " << to_utf8(stateText()));
+                       LYXERR(Debug::OUTFILE, "Color enabled. Font: " << to_utf8(stateText()));
        }
 
        // FIXME: Do something for background and soul package?
@@ -827,7 +836,7 @@ void Font::validate(LaTeXFeatures & features) const
            && lang_ != latex_language)
        {
                features.useLanguage(lang_);
-               LYXERR(Debug::LATEX, "Found language " << lang_->lang());
+               LYXERR(Debug::OUTFILE, "Found language " << lang_->lang());
        }
 }