From cb7094696095236b9a7133f41901e90aee767544 Mon Sep 17 00:00:00 2001 From: Enrico Forestieri Date: Sat, 10 Sep 2016 13:36:45 +0200 Subject: [PATCH] Fix bug #9616 --- src/Encoding.cpp | 10 ++++++++++ src/Encoding.h | 6 ++++++ src/mathed/InsetMathNest.cpp | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Encoding.cpp b/src/Encoding.cpp index 73edc843ff..acb91f656f 100644 --- a/src/Encoding.cpp +++ b/src/Encoding.cpp @@ -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 { diff --git a/src/Encoding.h b/src/Encoding.h index 5e289ca701..0f6e8ff438 100644 --- a/src/Encoding.h +++ b/src/Encoding.h @@ -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. */ diff --git a/src/mathed/InsetMathNest.cpp b/src/mathed/InsetMathNest.cpp index 223e31afc2..4216145e8a 100644 --- a/src/mathed/InsetMathNest.cpp +++ b/src/mathed/InsetMathNest.cpp @@ -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);