]> git.lyx.org Git - features.git/commitdiff
Properly determine active font encoding
authorJuergen Spitzmueller <spitz@lyx.org>
Thu, 2 Apr 2015 15:13:45 +0000 (17:13 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Thu, 2 Apr 2015 15:13:45 +0000 (17:13 +0200)
src/BufferParams.cpp
src/BufferParams.h
src/Paragraph.cpp

index 032420bad62cf5d2ffd8095232687bf72faef706..a12a2860dc037d4c7d87a068b998180c278e5ded 100644 (file)
@@ -1499,18 +1499,8 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
        // XeTeX and LuaTeX (with OS fonts) do not need fontenc
        if (!useNonTeXFonts && !features.isProvided("fontenc")
            && font_encoding() != "default") {
-               vector<string> fontencs;
-               // primary language font encoding and default encoding
-               if (ascii_lowercase(language->fontenc()) != "none") {
-                       vector<string> fencs = getVectorFromString(font_encoding());
-                       fontencs.insert(fontencs.end(), fencs.begin(), fencs.end());
-                       fencs = getVectorFromString(language->fontenc());
-                       vector<string>::const_iterator fit = fencs.begin();
-                       for (; fit != fencs.end(); ++fit) {
-                               if (find(fontencs.begin(), fontencs.end(), *fit) == fontencs.end())
-                                       fontencs.push_back(*fit);
-                       }
-               }
+               // get main font encodings
+               vector<string> fontencs = font_encodings();
                // get font encodings of secondary languages
                features.getFontEncodings(fontencs);
                if (!fontencs.empty()) {
@@ -2762,7 +2752,31 @@ string const BufferParams::dvips_options() const
 
 string const BufferParams::font_encoding() const
 {
-       return (fontenc == "global") ? lyxrc.fontenc : fontenc;
+       return font_encodings().empty() ? "default" : font_encodings().back();
+}
+
+
+vector<string> const BufferParams::font_encodings() const
+{
+       string doc_fontenc = (fontenc == "global") ? lyxrc.fontenc : fontenc;
+
+       vector<string> fontencs;
+
+       // "default" means "no explicit font encoding"
+       if (doc_fontenc != "default") {
+               fontencs = getVectorFromString(doc_fontenc);
+               if (!language->fontenc().empty()
+                   && ascii_lowercase(language->fontenc()) != "none") {
+                       vector<string> fencs = getVectorFromString(language->fontenc());
+                       vector<string>::const_iterator fit = fencs.begin();
+                       for (; fit != fencs.end(); ++fit) {
+                               if (find(fontencs.begin(), fontencs.end(), *fit) == fontencs.end())
+                                       fontencs.push_back(*fit);
+                       }
+               }
+       }
+
+       return fontencs;
 }
 
 
index 2ff8ece309f26eaedc236fff3316928413fae2ad..3258b822fd54b63fc91d9fdcc96ec448e08919b4 100644 (file)
@@ -244,7 +244,7 @@ public:
        std::string bibtex_command;
        /// customized index processor
        std::string index_command;
-       /// font encoding
+       /// font encoding(s) requested for this document
        std::string fontenc;
        /// the rm font
        std::string fonts_roman;
@@ -383,8 +383,12 @@ public:
        /// map of the file's author IDs to AuthorList indexes
        typedef std::map<int, int> AuthorMap;
        AuthorMap author_map;
-       /// the buffer's font encoding
+       /// the buffer's active font encoding
        std::string const font_encoding() const;
+       /// all font encodings requested by the prefs/document/main language.
+       /// This does NOT include font encodings required by secondary languages
+       std::vector<std::string> const font_encodings() const;
+
        ///
        std::string const dvips_options() const;
        /** The return value of paperSizeName() depends on the
index 3ce354cc940a03e3529f601604601b506eebeb25..906a0695324237ca0807fef2dc12ca759e7e7ffd 100644 (file)
@@ -1154,10 +1154,11 @@ void Paragraph::Private::latexSpecialChar(otexstream & os,
                return;
        // If T1 font encoding is used, use the special
        // characters it provides.
-       // NOTE: some languages reset the font encoding
-       // internally
+       // NOTE: Some languages reset the font encoding internally.
+       //       If we are using such a language, we do not output
+       //       special T1 chars.
        if (!runparams.inIPA && !running_font.language()->internalFontEncoding()
-           && lyxrc.fontenc == "T1" && latexSpecialT1(c, os, i, column))
+           && bparams.font_encoding() == "T1" && latexSpecialT1(c, os, i, column))
                return;
 
        // Otherwise, we use what LaTeX provides us.