]> git.lyx.org Git - lyx.git/blobdiff - src/Font.cpp
Fix broken layout file syntax
[lyx.git] / src / Font.cpp
index 402db843080c759d3fc633e2d2085a6249b26970..6e7ab347337476df893c3ea763d7071891cad364 100644 (file)
@@ -332,7 +332,7 @@ int Font::latexWriteStartChanges(odocstream & os, BufferParams const & bparams,
                }
        }
 
-       // When the current language is Hebrew, Arabic, or Farsi
+       // If the current language is Hebrew, Arabic, or Farsi
        // the numbers are written Left-to-Right. ArabTeX package
        // reorders the number automatically but the packages used
        // for Hebrew and Farsi (Arabi) do not.
@@ -428,7 +428,7 @@ int Font::latexWriteStartChanges(odocstream & os, BufferParams const & bparams,
                }
                os << '\\'
                   << LaTeXSizeNames[f.size()]
-                  << ' ';
+                  << '{';
                count += strlen(LaTeXSizeNames[f.size()]) + 2;
        }
        return count;
@@ -438,7 +438,7 @@ int Font::latexWriteStartChanges(odocstream & os, BufferParams const & bparams,
 /// Writes ending block of LaTeX needed to close use of this font
 // Returns number of chars written
 // This one corresponds to latexWriteStartChanges(). (Asger)
-int Font::latexWriteEndChanges(odocstream & os, BufferParams const & bparams,
+int Font::latexWriteEndChanges(otexstream & os, BufferParams const & bparams,
                                  OutputParams const & runparams,
                                  Font const & base,
                                  Font const & next,
@@ -513,6 +513,8 @@ int Font::latexWriteEndChanges(odocstream & os, BufferParams const & bparams,
                        os << '}';
                        ++count;
                }
+               os << '}';
+               ++count;
        }
 
        // When the current language is Hebrew, Arabic, or Farsi
@@ -531,7 +533,7 @@ int Font::latexWriteEndChanges(odocstream & os, BufferParams const & bparams,
                // We need to close the encoding even if it does not change
                // to do correct environment nesting
                Encoding const * const ascii = encodings.fromLyXName("ascii");
-               pair<bool, int> const c = switchEncoding(os, bparams,
+               pair<bool, int> const c = switchEncoding(os.os(), bparams,
                                runparams, *ascii);
                LASSERT(c.first, /**/);
                count += c.second;
@@ -539,8 +541,9 @@ int Font::latexWriteEndChanges(odocstream & os, BufferParams const & bparams,
                open_encoding_ = false;
        }
 
-       if (closeLanguage &&
-                       language() != base.language() && language() != next.language()) {
+       if (closeLanguage
+           && language() != base.language() && language() != next.language()
+           && language()->encoding()->package() != Encoding::CJK) {
                os << '}';
                ++count;
        }
@@ -701,9 +704,10 @@ void Font::validate(LaTeXFeatures & features) const
 
        // FIXME: Do something for background and soul package?
 
-       if (lang_->babel() != doc_language->babel() &&
-               lang_ != ignore_language &&
-               lang_ != latex_language)
+       if (((features.usePolyglossia() && lang_->polyglossia() != doc_language->polyglossia())
+            || (features.useBabel(true) && lang_->babel() != doc_language->babel()))
+           && lang_ != ignore_language
+           && lang_ != latex_language)
        {
                features.useLanguage(lang_);
                LYXERR(Debug::LATEX, "Found language " << lang_->lang());