2008-09-04 22:24:07 +00:00
|
|
|
/**
|
|
|
|
* \file InsetMathEnsureMath.cpp
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author André Pönitz
|
2008-09-04 22:24:07 +00:00
|
|
|
* \author Enrico Forestieri
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "InsetMathEnsureMath.h"
|
|
|
|
|
2009-12-31 15:46:39 +00:00
|
|
|
#include "MathData.h"
|
Index: src/mathed/InsetMathEnsureMath.cpp
===================================================================
--- src/mathed/InsetMathEnsureMath.cpp (revisione 34304)
+++ src/mathed/InsetMathEnsureMath.cpp (copia locale)
@@ -13,8 +13,9 @@
#include "InsetMathEnsureMath.h"
-#include "MathStream.h"
#include "MathData.h"
+#include "MathStream.h"
+#include "MathSupport.h"
#include <ostream>
@@ -34,7 +35,8 @@ Inset * InsetMathEnsureMath::clone() con
void InsetMathEnsureMath::metrics(MetricsInfo & mi, Dimension & dim) const
{
- FontSetChanger dummy(mi.base, "mathnormal");
+ bool really_change_font = isTextFont(from_ascii(mi.base.fontname));
+ FontSetChanger dummy(mi.base, "mathnormal", really_change_font);
cell(0).metrics(mi, dim);
metricsMarkers(dim);
}
@@ -42,7 +44,8 @@ void InsetMathEnsureMath::metrics(Metric
void InsetMathEnsureMath::draw(PainterInfo & pi, int x, int y) const
{
- FontSetChanger dummy(pi.base, "mathnormal");
+ bool really_change_font = isTextFont(from_ascii(pi.base.fontname));
+ FontSetChanger dummy(pi.base, "mathnormal", really_change_font);
cell(0).draw(pi, x, y);
drawMarkers(pi, x, y);
}
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34321 a592a061-630c-0410-9148-cb99ea01b6c8
2010-04-28 01:58:11 +00:00
|
|
|
#include "MathStream.h"
|
|
|
|
#include "MathSupport.h"
|
2008-09-04 22:24:07 +00:00
|
|
|
|
2016-06-04 08:41:13 +00:00
|
|
|
#include "LaTeXFeatures.h"
|
|
|
|
#include "MetricsInfo.h"
|
|
|
|
|
2008-09-04 22:24:07 +00:00
|
|
|
#include <ostream>
|
|
|
|
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
2009-11-08 11:45:46 +00:00
|
|
|
InsetMathEnsureMath::InsetMathEnsureMath(Buffer * buf)
|
|
|
|
: InsetMathNest(buf, 1)
|
2008-09-04 22:24:07 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
Inset * InsetMathEnsureMath::clone() const
|
|
|
|
{
|
|
|
|
return new InsetMathEnsureMath(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void InsetMathEnsureMath::metrics(MetricsInfo & mi, Dimension & dim) const
|
|
|
|
{
|
2016-11-22 10:26:15 +00:00
|
|
|
Changer dummy = mi.base.changeEnsureMath();
|
2008-09-04 22:24:07 +00:00
|
|
|
cell(0).metrics(mi, dim);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void InsetMathEnsureMath::draw(PainterInfo & pi, int x, int y) const
|
|
|
|
{
|
2016-11-22 10:26:15 +00:00
|
|
|
Changer dummy = pi.base.changeEnsureMath();
|
2008-09-04 22:24:07 +00:00
|
|
|
cell(0).draw(pi, x, y);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void InsetMathEnsureMath::metricsT(TextMetricsInfo const & mi, Dimension & dim) const
|
|
|
|
{
|
|
|
|
cell(0).metricsT(mi, dim);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void InsetMathEnsureMath::drawT(TextPainter & pain, int x, int y) const
|
|
|
|
{
|
|
|
|
cell(0).drawT(pain, x, y);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-26 19:04:36 +00:00
|
|
|
void InsetMathEnsureMath::write(TeXMathStream & os) const
|
2008-09-04 22:24:07 +00:00
|
|
|
{
|
|
|
|
ModeSpecifier specifier(os, MATH_MODE);
|
|
|
|
os << "\\ensuremath{" << cell(0) << "}";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-26 19:02:46 +00:00
|
|
|
void InsetMathEnsureMath::mathmlize(MathMLStream & ms) const
|
2009-12-26 15:01:03 +00:00
|
|
|
{
|
2019-05-09 23:52:07 +00:00
|
|
|
SetMode mathmode(ms, false);
|
|
|
|
ms << MTag("mstyle", "class='math'")
|
2011-04-01 22:34:40 +00:00
|
|
|
<< cell(0)
|
|
|
|
<< ETag("mstyle");
|
2011-04-01 21:18:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void InsetMathEnsureMath::htmlize(HtmlStream & os) const
|
|
|
|
{
|
|
|
|
SetHTMLMode mathmode(os, false);
|
2011-04-01 22:34:40 +00:00
|
|
|
os << MTag("span", "class='math'")
|
|
|
|
<< cell(0)
|
|
|
|
<< ETag("span");
|
2009-12-26 15:01:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-09-04 22:24:07 +00:00
|
|
|
void InsetMathEnsureMath::infoize(odocstream & os) const
|
|
|
|
{
|
|
|
|
os << "EnsureMath";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-01 22:34:40 +00:00
|
|
|
void InsetMathEnsureMath::validate(LaTeXFeatures & features) const
|
|
|
|
{
|
|
|
|
// FIXME XHTML
|
|
|
|
// It'd be better to be able to get this from an InsetLayout, but at present
|
|
|
|
// InsetLayouts do not seem really to work for things that aren't InsetTexts.
|
|
|
|
if (features.runparams().math_flavor == OutputParams::MathAsMathML)
|
2011-12-06 22:17:13 +00:00
|
|
|
features.addCSSSnippet("mstyle.math { font-style: italic; }");
|
2011-04-01 22:34:40 +00:00
|
|
|
else if (features.runparams().math_flavor == OutputParams::MathAsHTML)
|
2011-12-06 22:17:13 +00:00
|
|
|
features.addCSSSnippet("span.mathbox { font-style: italic; }");
|
2011-04-01 22:34:40 +00:00
|
|
|
|
|
|
|
InsetMathNest::validate(features);
|
|
|
|
}
|
|
|
|
|
2008-09-04 22:24:07 +00:00
|
|
|
} // namespace lyx
|