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
This commit is contained in:
Enrico Forestieri 2008-09-02 20:02:08 +00:00
parent 2cf4eabadc
commit ad91dd139c

View 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();
}