]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathFont.cpp
Get rid of Inset::setPosCache
[lyx.git] / src / mathed / InsetMathFont.cpp
index 020509ddf2a2776330e0650b02d8a6a9fb360a93..05f9e66e73b081b51fa5653343dfa75d8ff3abd9 100644 (file)
@@ -64,11 +64,29 @@ bool InsetMathFont::lockedMode() const
 }
 
 
+void InsetMathFont::write(WriteStream & os) const
+{
+       // Close the mode changing command inserted during export if
+       // we are going to output another mode changing command that
+       // actually doesn't change mode. This avoids exporting things
+       // such as \ensuremath{a\mathit{b}} or \textit{a\text{b}} and
+       // produce instead \ensuremath{a}\mathit{b} and \textit{a}\text{b}.
+       if (os.pendingBrace()
+           && ((currentMode() == TEXT_MODE && os.textMode())
+                   || (currentMode() == MATH_MODE && !os.textMode()))) {
+               os.os() << '}';
+               os.pendingBrace(false);
+               os.textMode(!os.textMode());
+       }
+       InsetMathNest::write(os);
+}
+
+
 void InsetMathFont::metrics(MetricsInfo & mi, Dimension & dim) const
 {
        Changer dummy = mi.base.changeFontSet(font());
        cell(0).metrics(mi, dim);
-       metricsMarkers(dim);
+       metricsMarkers(mi, dim);
 }
 
 
@@ -77,7 +95,6 @@ void InsetMathFont::draw(PainterInfo & pi, int x, int y) const
        Changer dummy = pi.base.changeFontSet(font());
        cell(0).draw(pi, x + 1, y);
        drawMarkers(pi, x, y);
-       setPosCache(pi, x, y);
 }