mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 05:16:21 +00:00
Move font encoding information to languages.
This commit is contained in:
parent
9397e15aa7
commit
16c33b5f6e
@ -10,6 +10,7 @@
|
||||
# PolyglossiaName <polyglossianame>
|
||||
# PolyglossiaOpts "<language-specific options>"
|
||||
# Encoding <encoding>
|
||||
# FontEncoding <font encoding>
|
||||
# QuoteStyle <danish|english|french|german|polish|swedish>
|
||||
# InternalEncoding <true|false>
|
||||
# RTL <true|false>
|
||||
@ -45,6 +46,8 @@
|
||||
# Default"
|
||||
# * InternalEncoding is used to tell LyX that babel internally sets a font
|
||||
# encoding (such as hebrew to LHE). See bug #5091.
|
||||
# * "FontEncoding none" tells LyX that fontenc should not be loaded with this
|
||||
# language.
|
||||
# * AsBabelOptions advices LyX to pass the languages locally to babel, not
|
||||
# globally to the class. Some languages (basically those not directly
|
||||
# supported by babel) need this.
|
||||
@ -143,6 +146,7 @@ Language arabic_arabi
|
||||
PolyglossiaName arabic
|
||||
QuoteStyle french
|
||||
Encoding cp1256
|
||||
FontEncoding "LFE,LAE"
|
||||
RTL true
|
||||
AsBabelOptions true
|
||||
LangCode ar_SA
|
||||
@ -410,6 +414,7 @@ Language farsi
|
||||
BabelName farsi
|
||||
PolyglossiaName farsi
|
||||
Encoding utf8
|
||||
FontEncoding "LFE,LAE"
|
||||
RTL true
|
||||
LangCode fa_IR
|
||||
PostBabelPreamble
|
||||
@ -511,6 +516,7 @@ Language greek
|
||||
QuoteStyle french
|
||||
Encoding iso8859-7
|
||||
InternalEncoding true
|
||||
FontEncoding "LGR"
|
||||
LangCode el_GR
|
||||
End
|
||||
|
||||
@ -522,6 +528,7 @@ Language polutonikogreek
|
||||
QuoteStyle french
|
||||
Encoding iso8859-7
|
||||
InternalEncoding true
|
||||
FontEncoding "LGR"
|
||||
LangCode el_GR
|
||||
End
|
||||
|
||||
@ -532,6 +539,7 @@ Language hebrew
|
||||
Encoding cp1255
|
||||
QuoteStyle english
|
||||
InternalEncoding true
|
||||
FontEncoding "LHE"
|
||||
RTL true
|
||||
LangCode he_IL
|
||||
End
|
||||
@ -605,6 +613,7 @@ Language japanese
|
||||
AsBabelOptions true
|
||||
Requires japanese
|
||||
InternalEncoding true
|
||||
FontEncoding None
|
||||
End
|
||||
|
||||
# uses CJK package
|
||||
|
@ -1491,32 +1491,26 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
|
||||
<< from_ascii(fonts_default_family) << "}\n";
|
||||
|
||||
// set font encoding
|
||||
// for arabic_arabi and farsi we also need to load the LAE and
|
||||
// LFE encoding
|
||||
// XeTeX and LuaTeX (with OS fonts) work without fontenc
|
||||
if (font_encoding() != "default" && language->lang() != "japanese"
|
||||
&& !useNonTeXFonts && !features.isProvided("fontenc")) {
|
||||
docstring extra_encoding;
|
||||
if (features.mustProvide("textgreek"))
|
||||
extra_encoding += from_ascii("LGR");
|
||||
if (features.mustProvide("textcyr")) {
|
||||
if (!extra_encoding.empty())
|
||||
extra_encoding.push_back(',');
|
||||
extra_encoding += from_ascii("T2A");
|
||||
// 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);
|
||||
}
|
||||
if (!extra_encoding.empty() && !font_encoding().empty())
|
||||
extra_encoding.push_back(',');
|
||||
size_t fars = language_options.str().find("farsi");
|
||||
size_t arab = language_options.str().find("arabic");
|
||||
if (language->lang() == "arabic_arabi"
|
||||
|| language->lang() == "farsi" || fars != string::npos
|
||||
|| arab != string::npos) {
|
||||
os << "\\usepackage[" << extra_encoding
|
||||
<< from_ascii(font_encoding())
|
||||
<< ",LFE,LAE]{fontenc}\n";
|
||||
} else {
|
||||
os << "\\usepackage[" << extra_encoding
|
||||
<< from_ascii(font_encoding())
|
||||
}
|
||||
// get font encodings of secondary languages
|
||||
features.getFontEncodings(fontencs);
|
||||
if (!fontencs.empty()) {
|
||||
os << "\\usepackage["
|
||||
<< from_ascii(getStringFromVector(fontencs))
|
||||
<< "]{fontenc}\n";
|
||||
}
|
||||
}
|
||||
|
@ -666,6 +666,30 @@ set<string> LaTeXFeatures::getEncodingSet(string const & doc_encoding) const
|
||||
return encodings;
|
||||
}
|
||||
|
||||
|
||||
void LaTeXFeatures::getFontEncodings(vector<string> & encodings) const
|
||||
{
|
||||
// these must be loaded if glyphs of this script
|
||||
// are used (notwithstanding the language)
|
||||
if (mustProvide("textgreek"))
|
||||
encodings.insert(encodings.begin(), "LGR");
|
||||
if (mustProvide("textcyr"))
|
||||
encodings.insert(encodings.begin(), "T2A");
|
||||
|
||||
LanguageList::const_iterator it = UsedLanguages_.begin();
|
||||
LanguageList::const_iterator end = UsedLanguages_.end();
|
||||
for (; it != end; ++it)
|
||||
if (!(*it)->fontenc().empty()
|
||||
&& ascii_lowercase((*it)->fontenc()) != "none") {
|
||||
vector<string> extraencs = getVectorFromString((*it)->fontenc());
|
||||
vector<string>::const_iterator fit = extraencs.begin();
|
||||
for (; fit != extraencs.end(); ++fit) {
|
||||
if (find(encodings.begin(), encodings.end(), *fit) == encodings.end())
|
||||
encodings.insert(encodings.begin(), *fit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
char const * simplefeatures[] = {
|
||||
|
@ -128,6 +128,8 @@ public:
|
||||
///
|
||||
std::set<std::string> getEncodingSet(std::string const & doc_encoding) const;
|
||||
///
|
||||
void getFontEncodings(std::vector<std::string> & encodings) const;
|
||||
///
|
||||
void useLayout(docstring const & lyt);
|
||||
///
|
||||
void useInsetLayout(InsetLayout const & lay);
|
||||
|
@ -72,6 +72,7 @@ bool Language::readLanguage(Lexer & lex)
|
||||
LA_BABELNAME,
|
||||
LA_ENCODING,
|
||||
LA_END,
|
||||
LA_FONTENC,
|
||||
LA_GUINAME,
|
||||
LA_INTERNAL_ENC,
|
||||
LA_LANG_CODE,
|
||||
@ -91,6 +92,7 @@ bool Language::readLanguage(Lexer & lex)
|
||||
{ "babelname", LA_BABELNAME },
|
||||
{ "encoding", LA_ENCODING },
|
||||
{ "end", LA_END },
|
||||
{ "fontencoding", LA_FONTENC },
|
||||
{ "guiname", LA_GUINAME },
|
||||
{ "internalencoding", LA_INTERNAL_ENC },
|
||||
{ "langcode", LA_LANG_CODE },
|
||||
@ -145,6 +147,9 @@ bool Language::readLanguage(Lexer & lex)
|
||||
case LA_ENCODING:
|
||||
lex >> encodingStr_;
|
||||
break;
|
||||
case LA_FONTENC:
|
||||
lex >> fontenc_;
|
||||
break;
|
||||
case LA_GUINAME:
|
||||
lex >> display_;
|
||||
break;
|
||||
|
@ -76,6 +76,8 @@ public:
|
||||
std::string const babel_presettings() const { return babel_presettings_; }
|
||||
/// This language internally sets a font encoding
|
||||
bool internalFontEncoding() const { return internal_enc_; }
|
||||
/// fontenc encoding(s)
|
||||
std::string const fontenc() const { return fontenc_; }
|
||||
/// This language needs to be passed to babel itself (not the class)
|
||||
bool asBabelOptions() const { return as_babel_options_; }
|
||||
///
|
||||
@ -118,6 +120,8 @@ private:
|
||||
///
|
||||
trivstring babel_presettings_;
|
||||
///
|
||||
trivstring fontenc_;
|
||||
///
|
||||
bool internal_enc_;
|
||||
///
|
||||
bool as_babel_options_;
|
||||
|
Loading…
Reference in New Issue
Block a user