From: Enrico Forestieri Date: Tue, 2 Sep 2008 20:02:08 +0000 (+0000) Subject: Take into account the latex encoding when generating math preview snippets. X-Git-Tag: 1.6.10~3562 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=ad91dd139c4d6665704b11d9bd34770c3b769543;p=features.git Take into account the latex encoding when generating math preview snippets. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26287 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp index e7748cec1e..dffbee7e67 100644 --- a/src/mathed/InsetMathHull.cpp +++ b/src/mathed/InsetMathHull.cpp @@ -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(); }