X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FEncoding.cpp;h=48e9271395fc43dcdf5bafca902b8067e14dbdec;hb=90f7007a2e6c78ffd031e4636ff909ab1bc2ddec;hp=6447e33eecad05daa7d380b3a59c50229a3bd7cb;hpb=8bf5d4b4614bc45e727112cdb20e162da3e26717;p=lyx.git diff --git a/src/Encoding.cpp b/src/Encoding.cpp index 6447e33eec..48e9271395 100644 --- a/src/Encoding.cpp +++ b/src/Encoding.cpp @@ -305,8 +305,9 @@ const char * EncodingException::what() const throw() Encoding::Encoding(string const & n, string const & l, string const & g, - string const & i, bool f, Encoding::Package p) - : name_(n), latexName_(l), guiName_(g), iconvName_(i), fixedwidth_(f), package_(p) + string const & i, bool f, bool u, Encoding::Package p) + : name_(n), latexName_(l), guiName_(g), iconvName_(i), fixedwidth_(f), + unsafe_(u), package_(p) { if (n == "ascii") { // ASCII can encode 128 code points and nothing else @@ -697,9 +698,11 @@ void Encodings::validate(char_type c, LaTeXFeatures & features, bool for_mathed) bool const use_text = (for_mathed && isTextCmd(c)) || (!for_mathed && !it->second.textcommand.empty()); bool const plain_utf8 = (features.runparams().encoding->name() == "utf8-plain"); + bool const unicode_math = (features.isRequired("unicode-math") + && features.isAvailable("unicode-math")); // with utf8-plain, we only load packages when in mathed (see #7766) // and if we do not use unicode-math - if ((math_mode && !features.isRequired("unicode-math")) + if ((math_mode && !unicode_math) || (use_math && !plain_utf8)) { if (!it->second.mathpreamble.empty()) { if (it->second.mathfeature()) { @@ -821,14 +824,18 @@ bool Encodings::isMathAlpha(char_type c) } -Encoding const * Encodings::fromLyXName(string const & name) const +Encoding const * +Encodings::fromLyXName(string const & name, bool allowUnsafe) const { EncodingList::const_iterator const it = encodinglist.find(name); + if (!allowUnsafe && it->second.unsafe()) + return 0; return it != encodinglist.end() ? &it->second : 0; } -Encoding const * Encodings::fromLaTeXName(string const & n) const +Encoding const * +Encodings::fromLaTeXName(string const & n, bool allowUnsafe) const { string name = n; // FIXME: if we have to test for too many of these synonyms, @@ -843,15 +850,17 @@ Encoding const * Encodings::fromLaTeXName(string const & n) const // most at the top of lib/encodings. EncodingList::const_iterator const end = encodinglist.end(); for (EncodingList::const_iterator it = encodinglist.begin(); it != end; ++it) - if (it->second.latexName() == name) + if (it->second.latexName() == name) { + if (!allowUnsafe && it->second.unsafe()) + return 0; return &it->second; + } return 0; } Encodings::Encodings() -{ -} +{} void Encodings::read(FileName const & encfile, FileName const & symbolsfile) @@ -1004,10 +1013,15 @@ void Encodings::read(FileName const & encfile, FileName const & symbolsfile) lex.next(); string const width = lex.getString(); bool fixedwidth = false; + bool unsafe = false; if (width == "fixed") fixedwidth = true; else if (width == "variable") fixedwidth = false; + else if (width == "variableunsafe") { + fixedwidth = false; + unsafe = true; + } else lex.printError("Unknown width"); @@ -1027,7 +1041,8 @@ void Encodings::read(FileName const & encfile, FileName const & symbolsfile) LYXERR(Debug::INFO, "Reading encoding " << name); encodinglist[name] = Encoding(name, latexname, - guiname, iconvname, fixedwidth, package); + guiname, iconvname, fixedwidth, unsafe, + package); if (lex.lex() != et_end) lex.printError("Missing end");