From 5fec78f69fd44cd6cb064df1c632ef4a4b125242 Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Thu, 2 Apr 2015 17:13:45 +0200 Subject: [PATCH] Properly determine active font encoding --- src/BufferParams.cpp | 40 +++++++++++++++++++++++++++------------- src/BufferParams.h | 8 ++++++-- src/Paragraph.cpp | 7 ++++--- 3 files changed, 37 insertions(+), 18 deletions(-) diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index 032420bad6..a12a2860dc 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -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 fontencs; - // primary language font encoding and default encoding - if (ascii_lowercase(language->fontenc()) != "none") { - vector fencs = getVectorFromString(font_encoding()); - fontencs.insert(fontencs.end(), fencs.begin(), fencs.end()); - fencs = getVectorFromString(language->fontenc()); - vector::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 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 const BufferParams::font_encodings() const +{ + string doc_fontenc = (fontenc == "global") ? lyxrc.fontenc : fontenc; + + vector 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 fencs = getVectorFromString(language->fontenc()); + vector::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; } diff --git a/src/BufferParams.h b/src/BufferParams.h index 2ff8ece309..3258b822fd 100644 --- a/src/BufferParams.h +++ b/src/BufferParams.h @@ -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 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 const font_encodings() const; + /// std::string const dvips_options() const; /** The return value of paperSizeName() depends on the diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index 3ce354cc94..906a069532 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -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. -- 2.39.2