]> git.lyx.org Git - features.git/commitdiff
Take into account the latex encoding when generating math preview snippets.
authorEnrico Forestieri <forenr@lyx.org>
Tue, 2 Sep 2008 20:02:08 +0000 (20:02 +0000)
committerEnrico Forestieri <forenr@lyx.org>
Tue, 2 Sep 2008 20:02:08 +0000 (20:02 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26287 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/InsetMathHull.cpp

index e7748cec1e57cc683f40752b25062c9612ac0ee3..dffbee7e6786fb26e830d9d0c389945642ec0448 100644 (file)
@@ -35,6 +35,7 @@
 #include "Cursor.h"
 #include "DispatchResult.h"
 #include "FuncRequest.h"
+#include "Language.h"
 #include "LyXRC.h"
 #include "OutputParams.h"
 #include "ParIterator.h"
@@ -445,7 +446,12 @@ void InsetMathHull::drawT(TextPainter & pain, int x, int y) const
 static docstring latexString(InsetMathHull const & inset)
 {
        odocstringstream ls;
-       WriteStream wi(ls, false, false, false);
+       // This has to be static, because a preview snippet containing math
+       // in text mode (such as $\text{$\phi$}$) gets processed twice. The
+       // first time as a whole, and the second time only the inner math.
+       // In this last case inset.buffer() would be invalid.
+       static Encoding const * encoding = inset.buffer().language()->encoding();
+       WriteStream wi(ls, false, true, false, encoding);
        inset.write(wi);
        return ls.str();
 }