#include "graphics/PreviewLoader.h"
#include "frontends/alert.h"
+#include "frontends/FontMetrics.h"
#include "frontends/Painter.h"
#include "support/convert.h"
void InsetMathHull::metrics(MetricsInfo & mi, Dimension & dim) const
{
- // true value in LaTeX is 12pt plus 3pt minus 9pt
- // FIXME: even better would be to handle the short skip case.
- int const display_margin = display() ? mi.base.inPixels(Length(12, Length::PT)) : 0;
+ /* Compute \(above|below)displayskip
+ true value in LaTeX is 10pt plus 2pt minus 5pt (in normal size at 10pt)
+ FIXME: make this dependent of current size? (minor improvement)
+ FIXME: if would be nice if this was not part of the inset, but
+ just increased the row ascent/descent.
+ FIXME: even better would be to handle the short skip case.
+ */
+ int const bottom_display_margin = mi.base.inPixels(Length(10, Length::PT));
+ int top_display_margin = bottom_display_margin;
+ // at start of paragraph, add an empty line
+ if (mi.vmode)
+ top_display_margin += theFontMetrics(mi.base.font).maxHeight() + 2;
if (previewState(mi.base.bv)) {
preview_->metrics(mi, dim);
// value was hardcoded to 1 pixel
dim.wid += mi.base.bv->zoomedPixels(1) ;
if (display()) {
- dim.asc += display_margin;
- dim.des += display_margin;
+ dim.asc += top_display_margin;
+ dim.des += bottom_display_margin;
}
}
return;
if (display()) {
- dim.asc += display_margin;
- dim.des += display_margin;
+ dim.asc += top_display_margin;
+ dim.des += bottom_display_margin;
}
// reserve some space for marker.
ColorCode pen_color = mouseHovered(pi.base.bv) || editing(pi.base.bv)?
Color_mathframe : Color_mathcorners;
// If the corners have the same color as the background, do not paint them.
- if (lcolor.getX11Name(Color_mathbg) == lcolor.getX11Name(pen_color))
+ if (lcolor.getX11HexName(Color_mathbg) == lcolor.getX11HexName(pen_color))
return;
Inset::drawMarkers(pi, x, y);
{
// Choose the tag around the MathML equation.
docstring name;
+ bool doCR = false;
if (getType() == hullSimple)
name = from_ascii("inlineequation");
- else
+ else {
+ doCR = true; // This is a block equation, always have <informalequation> on its own line.
name = from_ascii("informalequation");
+ }
// DocBook also has <equation>, but it comes with a title.
+ // TODO: recognise \tag from amsmath? This would allow having <equation> with a proper title.
docstring attr;
for (row_type i = 0; i < nrows(); ++i) {
}
}
+ if (doCR)
+ if (!xs.isLastTagCR())
+ xs << xml::CR();
+
xs << xml::StartTag(name, attr);
xs << xml::CR();
osmath << ostmp.str(); // osmath is not a XMLStream, so no need for XMLStream::ESCAPE_NONE.
ms << ETag("math");
} catch (MathExportException const &) {
- osmath << "MathML export failed. Please report this as a bug.";
+ ms.cr();
+ osmath << "<mathphrase>MathML export failed. Please report this as a bug.</mathphrase>";
}
// Output the complete formula to the DocBook stream.
xs << XMLStream::ESCAPE_NONE << osmath.str();
xs << xml::CR();
xs << xml::EndTag(name);
+ if (doCR)
+ xs << xml::CR();
}