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
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()) {
}
-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,
// 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)
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");
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");