This commit is contained in:
Enrico Forestieri 2016-09-10 13:36:45 +02:00
parent 67db7e1c10
commit cb70946960
3 changed files with 17 additions and 1 deletions

View File

@ -601,6 +601,16 @@ bool Encodings::isMathAlpha(char_type c)
}
bool Encodings::isUnicodeTextOnly(char_type c)
{
if (isASCII(c) || isMathAlpha(c))
return false;
CharInfoMap::const_iterator const it = unicodesymbols.find(c);
return it == unicodesymbols.end() || it->second.mathcommand().empty();
}
Encoding const *
Encodings::fromLyXName(string const & name, bool allowUnsafe) const
{

View File

@ -286,6 +286,12 @@ public:
* letters and accented characters that are output as math commands.
*/
static bool isMathAlpha(char_type c);
/**
* Do we have to wrap in \text this character when in mathmode?
* This is true if \p c is not ascii and the "mathalpha" flag is not
* set and a mathcommand is not defined in the unicodesymbols file.
*/
static bool isUnicodeTextOnly(char_type c);
/**
* Register \p c as a mathmode command.
*/

View File

@ -1856,7 +1856,7 @@ bool InsetMathNest::interpretChar(Cursor & cur, char_type const c)
cur.niceInsert(createInsetMath("sim", buf));
return true;
}
if (currentMode() == InsetMath::MATH_MODE && !isAsciiOrMathAlpha(c)) {
if (currentMode() == InsetMath::MATH_MODE && Encodings::isUnicodeTextOnly(c)) {
MathAtom at = createInsetMath("text", buf);
at.nucleus()->cell(0).push_back(MathAtom(new InsetMathChar(c)));
cur.niceInsert(at);