Properly determine active font encoding

This commit is contained in:
Juergen Spitzmueller 2015-04-02 17:13:45 +02:00
parent b309fa5d2b
commit 5fec78f69f
3 changed files with 37 additions and 18 deletions

View File

@ -1499,18 +1499,8 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
// XeTeX and LuaTeX (with OS fonts) do not need fontenc // XeTeX and LuaTeX (with OS fonts) do not need fontenc
if (!useNonTeXFonts && !features.isProvided("fontenc") if (!useNonTeXFonts && !features.isProvided("fontenc")
&& font_encoding() != "default") { && font_encoding() != "default") {
vector<string> fontencs; // get main font encodings
// primary language font encoding and default encoding vector<string> fontencs = font_encodings();
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 font encodings of secondary languages // get font encodings of secondary languages
features.getFontEncodings(fontencs); features.getFontEncodings(fontencs);
if (!fontencs.empty()) { if (!fontencs.empty()) {
@ -2762,7 +2752,31 @@ string const BufferParams::dvips_options() const
string const BufferParams::font_encoding() 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;
} }

View File

@ -244,7 +244,7 @@ public:
std::string bibtex_command; std::string bibtex_command;
/// customized index processor /// customized index processor
std::string index_command; std::string index_command;
/// font encoding /// font encoding(s) requested for this document
std::string fontenc; std::string fontenc;
/// the rm font /// the rm font
std::string fonts_roman; std::string fonts_roman;
@ -383,8 +383,12 @@ public:
/// map of the file's author IDs to AuthorList indexes /// map of the file's author IDs to AuthorList indexes
typedef std::map<int, int> AuthorMap; typedef std::map<int, int> AuthorMap;
AuthorMap author_map; AuthorMap author_map;
/// the buffer's font encoding /// the buffer's active font encoding
std::string const font_encoding() const; 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; std::string const dvips_options() const;
/** The return value of paperSizeName() depends on the /** The return value of paperSizeName() depends on the

View File

@ -1154,10 +1154,11 @@ void Paragraph::Private::latexSpecialChar(otexstream & os,
return; return;
// If T1 font encoding is used, use the special // If T1 font encoding is used, use the special
// characters it provides. // characters it provides.
// NOTE: some languages reset the font encoding // NOTE: Some languages reset the font encoding internally.
// internally // If we are using such a language, we do not output
// special T1 chars.
if (!runparams.inIPA && !running_font.language()->internalFontEncoding() 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; return;
// Otherwise, we use what LaTeX provides us. // Otherwise, we use what LaTeX provides us.