X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmathed%2FInsetMathFont.cpp;h=2a0cb997aa15636665d5df6b046e731b151c8eae;hb=d9082639080b9de993742bd352f92e5183058cf5;hp=020509ddf2a2776330e0650b02d8a6a9fb360a93;hpb=e3625b5b8052e75e8741152bdfd313b54969c675;p=lyx.git diff --git a/src/mathed/InsetMathFont.cpp b/src/mathed/InsetMathFont.cpp index 020509ddf2..2a0cb997aa 100644 --- a/src/mathed/InsetMathFont.cpp +++ b/src/mathed/InsetMathFont.cpp @@ -58,9 +58,25 @@ InsetMath::mode_type InsetMathFont::currentMode() const bool InsetMathFont::lockedMode() const { - if (key_->extra == "forcetext") - return true; - return false; + return key_->extra == "forcetext"; +} + + +void InsetMathFont::write(TeXMathStream & 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); } @@ -68,16 +84,13 @@ void InsetMathFont::metrics(MetricsInfo & mi, Dimension & dim) const { Changer dummy = mi.base.changeFontSet(font()); cell(0).metrics(mi, dim); - metricsMarkers(dim); } 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); + cell(0).draw(pi, x, y); } @@ -119,6 +132,8 @@ void InsetMathFont::validate(LaTeXFeatures & features) const features.require("tipa"); if (fontname == "ce" || fontname == "cf") features.require("mhchem"); + if (fontname == "mathds") + features.require("dsfont"); } else if (features.runparams().math_flavor == OutputParams::MathAsHTML) { features.addCSSSnippet( "span.normal{font: normal normal normal inherit serif;}\n" @@ -148,9 +163,11 @@ void InsetMathFont::htmlize(HtmlStream & os) const variant = "normal"; else if (tag == "frak" || tag == "mathfrak") variant = "fraktur"; - else if (tag == "mathbb" || tag == "mathbf" - || tag == "textbf") + else if (tag == "mathbf" || tag == "textbf") variant = "bold"; + else if (tag == "mathbb" || tag == "mathbbm" + || tag == "mathds") + variant = "double-struck"; else if (tag == "mathcal") variant = "script"; else if (tag == "mathit" || tag == "textsl" @@ -174,7 +191,7 @@ void InsetMathFont::htmlize(HtmlStream & os) const // The fonts we want to support are listed in lib/symbols -void InsetMathFont::mathmlize(MathStream & os) const +void InsetMathFont::mathmlize(MathMLStream & ms) const { // FIXME These are not quite right, because they do not nest // correctly. A proper fix would presumably involve tracking @@ -188,9 +205,11 @@ void InsetMathFont::mathmlize(MathStream & os) const variant = "normal"; else if (tag == "frak" || tag == "mathfrak") variant = "fraktur"; - else if (tag == "mathbb" || tag == "mathbf" - || tag == "textbf") + else if (tag == "mathbf" || tag == "textbf") variant = "bold"; + else if (tag == "mathbb" || tag == "mathbbm" + || tag == "mathds") + variant = "double-struck"; else if (tag == "mathcal") variant = "script"; else if (tag == "mathit" || tag == "textsl" @@ -202,18 +221,12 @@ void InsetMathFont::mathmlize(MathStream & os) const variant = "monospace"; // no support at present for textipa, textsc, noun - if (!variant.empty()) { - if (tag == "mathbb") { - os << MTag("mstyle", "class='mathbb' mathvariant='" + variant + "'") - << cell(0) - << ETag("mstyle"); - } else { - os << MTag("mstyle", "mathvariant='" + variant + "'") - << cell(0) - << ETag("mstyle"); - } - } else - os << cell(0); + if (!variant.empty()) + ms << MTag("mstyle", "mathvariant='" + variant + "'") + << cell(0) + << ETag("mstyle"); + else + ms << cell(0); }