]> git.lyx.org Git - features.git/commitdiff
MathML for InsetMathFont. Unfortunately, this does not seem to render at
authorRichard Heck <rgheck@comcast.net>
Thu, 31 Dec 2009 16:59:56 +0000 (16:59 +0000)
committerRichard Heck <rgheck@comcast.net>
Thu, 31 Dec 2009 16:59:56 +0000 (16:59 +0000)
the moment in Firefox, but it is the right way to do it.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32697 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/InsetMathFont.cpp
src/mathed/InsetMathFont.h

index 57078817d6166c6901e863544ffb488f4ca23cf2..e3271f8ccad17d22c311505519b0b89de3b65921 100644 (file)
@@ -106,6 +106,41 @@ void InsetMathFont::validate(LaTeXFeatures & features) const
 }
 
 
+// The fonts we want to support are listed in lib/symbols
+void InsetMathFont::mathmlize(MathStream & os) const
+{
+       // FIXME These are not quite right, because they do not nest
+       // correctly. A proper fix would presumably involve tracking
+       // the fonts already in effect.
+       std::string variant;
+       if (key_->name == "mathnormal" || key_->name == "mathrm"
+           || key_->name == "text" || key_->name == "textnormal"
+           || key_->name == "textrm" || key_->name == "textup"
+           || key_->name == "textmd")
+               variant = "normal";
+       else if (key_->name == "frak" || key_->name == "mathfrak")
+               variant = "fraktur";
+       else if (key_->name == "mathbb" || key_->name == "mathbf"
+                || key_->name == "textbf")
+               variant = "bold";
+       else if (key_->name == "mathcal")
+               variant == "script";
+       else if (key_->name == "mathit" || key_->name == "textsl"
+                || key_->name == "emph")
+               variant = "italic";
+       else if (key_->name == "mathsf" || key_->name == "textit"
+                || key_->name == "textsf")
+               variant = "sans-serif";
+       else if (key_->name == "mathtt" || key_->name == "texttt")
+               variant = "monospace";
+       // no support at present for textipa, textsc, noun
+       
+       if (!variant.empty())
+               os << "<mstyle mathvariant='" << from_utf8(variant) << "'>"
+                  << cell(0) << "</mstyle>";
+}
+
+
 void InsetMathFont::infoize(odocstream & os) const
 {
        os << "Font: " << key_->name;
index e687bc0ede2b861de3119fcc0b51090e20493310..926732b3dcaab21a3ba7f7017632f132c65a2eab 100644 (file)
@@ -46,6 +46,8 @@ public:
        ///
        void validate(LaTeXFeatures & features) const;
        ///
+       void mathmlize(MathStream &) const;
+       ///
        void infoize(odocstream & os) const;
        ///
        int kerning(BufferView const * bv) const { return cell(0).kerning(bv); }