]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/MathMacro.cpp
Fix display and export of some latex macros
[lyx.git] / src / mathed / MathMacro.cpp
index e01f7c213440528574c46b25c94977d094ea508a..4529cf92807800219d23035e59122ae78ab3706e 100644 (file)
@@ -30,6 +30,7 @@
 #include "LaTeXFeatures.h"
 #include "LyX.h"
 #include "LyXRC.h"
+#include "MetricsInfo.h"
 
 #include "frontends/Painter.h"
 
@@ -432,7 +433,7 @@ void MathMacro::metrics(MetricsInfo & mi, Dimension & dim) const
                if (lyxrc.macro_edit_style == LyXRC::MACRO_EDIT_INLINE_BOX
                    && d->editing_[mi.base.bv]) {
                        FontInfo font = mi.base.font;
-                       augmentFont(font, from_ascii("lyxtex"));
+                       augmentFont(font, "lyxtex");
                        Dimension namedim;
                        mathed_string_dim(font, name(), namedim);
 #if 0
@@ -551,10 +552,10 @@ void MathMacro::draw(PainterInfo & pi, int x, int y) const
        int expy = y;
 
        if (d->displayMode_ == DISPLAY_INIT || d->displayMode_ == DISPLAY_INTERACTIVE_INIT) {
-               FontSetChanger dummy(pi.base, "lyxtex");
+               Changer dummy = pi.base.changeFontSet("lyxtex");
                pi.pain.text(x, y, from_ascii("\\") + name(), pi.base.font);
        } else if (d->displayMode_ == DISPLAY_UNFOLDED) {
-               FontSetChanger dummy(pi.base, "lyxtex");
+               Changer dummy = pi.base.changeFontSet("lyxtex");
                pi.pain.text(x, y, from_ascii("\\"), pi.base.font);
                x += mathed_string_width(pi.base.font, from_ascii("\\")) + 1;
                cell(0).draw(pi, x, y);
@@ -613,6 +614,10 @@ void MathMacro::draw(PainterInfo & pi, int x, int y) const
                drawMarkers2(pi, expx, expy);
        } else {
                bool drawBox = lyxrc.macro_edit_style == LyXRC::MACRO_EDIT_INLINE_BOX;
+               bool upshape = d->macro_ && d->macro_->symbol()
+                               && d->macro_->symbol()->extra == "textmode";
+               Changer dummy = pi.base.font.changeShape(upshape ? UP_SHAPE
+                                                       : pi.base.font.shape());
 
                // warm up cells
                for (size_t i = 0; i < nargs(); ++i)
@@ -621,7 +626,7 @@ void MathMacro::draw(PainterInfo & pi, int x, int y) const
                if (drawBox && d->editing_[pi.base.bv]) {
                        // draw header and rectangle around
                        FontInfo font = pi.base.font;
-                       augmentFont(font, from_ascii("lyxtex"));
+                       augmentFont(font, "lyxtex");
                        font.setSize(FONT_SIZE_TINY);
                        font.setColor(Color_mathmacrolabel);
                        Dimension namedim;
@@ -924,7 +929,12 @@ bool MathMacro::folded() const
 
 void MathMacro::write(WriteStream & os) const
 {
-       MathEnsurer ensurer(os, d->macro_ != 0, true);
+       bool const textmode_macro = d->macro_ && d->macro_->symbol()
+                               && d->macro_->symbol()->extra == "textmode";
+       bool const needs_mathmode = d->macro_ && (!d->macro_->symbol()
+                               || d->macro_->symbol()->extra != "textmode");
+
+       MathEnsurer ensurer(os, needs_mathmode, true, textmode_macro);
 
        // non-normal mode
        if (d->displayMode_ != DISPLAY_NORMAL) {
@@ -1008,7 +1018,7 @@ void MathMacro::mathmlize(MathStream & os) const
                docstring const xmlname = d->macro_->xmlname();
                if (!xmlname.empty()) {
                        char const * type = d->macro_->MathMLtype();
-                       os << '<' << type << "> " << xmlname << " /<"
+                       os << '<' << type << "> " << xmlname << " </"
                           << type << '>';
                        return;
                }