]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/formula.C
Fix.
[lyx.git] / src / mathed / formula.C
index d8924ddf89798832bb077f1d1a18286a63ca0a78..b586aea753727ddc281985cd2879ff12701b7e4c 100644 (file)
@@ -13,9 +13,6 @@
 *   the GNU General Public Licence version 2 or later.
 */
 
-#ifdef __GNUG__
-#pragma implementation
-#endif
 
 #include <config.h>
 
@@ -127,7 +124,7 @@ Inset * InsetFormula::clone(Buffer const &, bool) const
 void InsetFormula::write(Buffer const *, ostream & os) const
 {
        WriteStream wi(os, false, false);
-       os << par_->fileInsetLabel() << " ";
+       os << par_->fileInsetLabel() << ' ';
        par_->write(wi);
 }
 
@@ -142,7 +139,7 @@ int InsetFormula::latex(Buffer const *, ostream & os, bool fragile, bool) const
 
 int InsetFormula::ascii(Buffer const *, ostream & os, int) const
 {
-       if (display()) {
+       if (0 && display()) {
                TextMetricsInfo mi;
                par()->metricsT(mi);
                TextPainter tpain(par()->width(), par()->height());
@@ -213,7 +210,7 @@ void InsetFormula::draw(BufferView * bv, LyXFont const & font,
        MathPainterInfo pi(bv->painter());
 
        if (use_preview) {
-               pi.pain.image(x, y - a, w, h,
+               pi.pain.image(x + 1, y - a, w, h,   // one pixel gap in front
                              *(preview_->pimage()->image(*this, *bv)));
        } else {
                pi.base.style = LM_ST_TEXT;
@@ -291,7 +288,8 @@ int InsetFormula::width(BufferView * bv, LyXFont const & font) const
 {
        metrics(bv, font);
        return preview_->previewReady() ?
-               preview_->pimage()->width() : par_->width();
+               1 + preview_->pimage()->width() : par_->width();
+               // insert a one pixel gap in front of the formula
 }
 
 
@@ -330,20 +328,5 @@ string const InsetFormula::PreviewImpl::latexString() const
        ostringstream ls;
        WriteStream wi(ls, false, false);
        parent().par_->write(wi);
-       string str = ls.str().c_str();
-
-       // If we are in displaymode, the preview will include the margins
-       // on either side of the previewed equation.
-       // We can create an image with a tight bounding box by replacing the
-       // "\[ ... \]" delimiters with "$ \displaystyle ... $".
-       // Note that we have to get rid of any trailing '\n's for the fix
-       // to work.
-       if (prefixIs(str, "\\[")) {
-               std::cerr << "before\n" << str << std::endl;
-               str = rtrim(rtrim(ltrim(str, "\\["), "\n"), "\\]");
-               str = "$ \\displaystyle " + str + " $";
-               std::cerr << "after\n" << str << std::endl;
-       }
-
-       return str;
+       return STRCONV(ls.str());
 }