#include "MetricsInfo.h"
#include "OutputParams.h"
#include "output_xhtml.h"
+#include "texstream.h"
#include "support/debug.h"
#include "support/docstream.h"
}
+Inset::RowFlags InsetSpace::rowFlags() const
+{
+ switch (params_.kind) {
+ case InsetSpaceParams::PROTECTED:
+ case InsetSpaceParams::CUSTOM_PROTECTED:
+ case InsetSpaceParams::HFILL_PROTECTED:
+ case InsetSpaceParams::THIN:
+ case InsetSpaceParams::NEGTHIN:
+ case InsetSpaceParams::MEDIUM:
+ case InsetSpaceParams::NEGMEDIUM:
+ case InsetSpaceParams::THICK:
+ case InsetSpaceParams::NEGTHICK:
+ case InsetSpaceParams::ENSPACE:
+ case InsetSpaceParams::VISIBLE:
+ // no break after these
+ return Inline;
+ case InsetSpaceParams::NORMAL:
+ case InsetSpaceParams::QUAD:
+ case InsetSpaceParams::QQUAD:
+ case InsetSpaceParams::ENSKIP:
+ case InsetSpaceParams::CUSTOM:
+ case InsetSpaceParams::HFILL:
+ case InsetSpaceParams::DOTFILL:
+ case InsetSpaceParams::HRULEFILL:
+ case InsetSpaceParams::LEFTARROWFILL:
+ case InsetSpaceParams::RIGHTARROWFILL:
+ case InsetSpaceParams::UPBRACEFILL:
+ case InsetSpaceParams::DOWNBRACEFILL:
+ // these allow line breaking
+ break;
+ }
+ return CanBreakAfter;
+}
+
+
namespace {
int const arrow_size = 8;
}
void InsetSpace::metrics(MetricsInfo & mi, Dimension & dim) const
{
if (isHfill()) {
- // The metrics for this kinds are calculated externally in
- // \c TextMetrics::computeRowMetrics. Those are dummy value:
- dim = Dimension(10, 10, 10);
+ // The width for hfills is calculated externally in
+ // TextMetrics::setRowAlignment. The value of 5 is the
+ // minimal value when the hfill is not active.
+ dim = Dimension(5, 10, 10);
return;
}
frontend::FontMetrics const & fm = theFontMetrics(mi.base.font);
dim.asc = fm.maxAscent();
dim.des = fm.maxDescent();
+ int const em = fm.em();
switch (params_.kind) {
case InsetSpaceParams::THIN:
case InsetSpaceParams::NEGTHIN:
- dim.wid = fm.width(char_type('M')) / 6;
+ dim.wid = em / 6;
break;
case InsetSpaceParams::MEDIUM:
case InsetSpaceParams::NEGMEDIUM:
- dim.wid = fm.width(char_type('M')) / 4;
+ dim.wid = em / 4;
break;
case InsetSpaceParams::THICK:
case InsetSpaceParams::NEGTHICK:
- dim.wid = fm.width(char_type('M')) / 2;
+ dim.wid = em / 2;
break;
case InsetSpaceParams::PROTECTED:
case InsetSpaceParams::VISIBLE:
dim.wid = fm.width(char_type(' '));
break;
case InsetSpaceParams::QUAD:
- dim.wid = fm.width(char_type('M'));
+ dim.wid = em;
break;
case InsetSpaceParams::QQUAD:
- dim.wid = 2 * fm.width(char_type('M'));
+ dim.wid = 2 * em;
break;
case InsetSpaceParams::ENSPACE:
case InsetSpaceParams::ENSKIP:
- dim.wid = int(0.5 * fm.width(char_type('M')));
+ dim.wid = int(0.5 * em);
break;
case InsetSpaceParams::CUSTOM:
case InsetSpaceParams::CUSTOM_PROTECTED: {
- int const w =
- params_.length.len().inPixels(mi.base.textwidth,
- fm.width(char_type('M')));
+ int const w = mi.base.inPixels(params_.length.len());
int const minw = (w < 0) ? 3 * arrow_size : 4;
dim.wid = max(minw, abs(w));
break;
// shut up compiler
break;
}
- // Cache the inset dimension.
- setDimCache(mi, dim);
}
}
int const w = dim.wid;
- int const h = theFontMetrics(pi.base.font).ascent('x');
+ int const h = theFontMetrics(pi.base.font).xHeight();
int xp[4], yp[4];
- xp[0] = x;
+ xp[0] = x + 1;
yp[0] = y - max(h / 4, 1);
if (params_.kind == InsetSpaceParams::NORMAL ||
params_.kind == InsetSpaceParams::PROTECTED ||
params_.kind == InsetSpaceParams::VISIBLE) {
- xp[1] = x; yp[1] = y;
- xp[2] = x + w; yp[2] = y;
+ xp[1] = x + 1; yp[1] = y;
+ xp[2] = x + w - 2; yp[2] = y;
} else {
- xp[1] = x; yp[1] = y + max(h / 4, 1);
- xp[2] = x + w; yp[2] = y + max(h / 4, 1);
+ xp[1] = x + 1; yp[1] = y + max(h / 4, 1);
+ xp[2] = x + w - 2; yp[2] = y + max(h / 4, 1);
}
- xp[3] = x + w;
+ xp[3] = x + w - 2;
yp[3] = y - max(h / 4, 1);
Color col = Color_special;
if (params_.kind == InsetSpaceParams::PROTECTED ||
params_.kind == InsetSpaceParams::ENSPACE ||
+ params_.kind == InsetSpaceParams::THIN ||
params_.kind == InsetSpaceParams::NEGTHIN ||
+ params_.kind == InsetSpaceParams::MEDIUM ||
params_.kind == InsetSpaceParams::NEGMEDIUM ||
+ params_.kind == InsetSpaceParams::THICK ||
params_.kind == InsetSpaceParams::NEGTHICK ||
params_.kind == InsetSpaceParams::CUSTOM_PROTECTED)
col = Color_latex;
void InsetSpaceParams::write(ostream & os) const
{
- string command;
switch (kind) {
case InsetSpaceParams::NORMAL:
os << "\\space{}";
kind = InsetSpaceParams::VISIBLE;
else if (command == "\\thinspace{}")
kind = InsetSpaceParams::THIN;
- else if (math && command == "\\medspace{}")
+ else if (command == "\\medspace{}")
kind = InsetSpaceParams::MEDIUM;
- else if (math && command == "\\thickspace{}")
+ else if (command == "\\thickspace{}")
kind = InsetSpaceParams::THICK;
else if (command == "\\quad{}")
kind = InsetSpaceParams::QUAD;
os << (runparams.free_spacing ? " " : "\\,");
break;
case InsetSpaceParams::MEDIUM:
- os << (runparams.free_spacing ? " " : "\\:");
+ if (params_.math)
+ os << (runparams.free_spacing ? " " : "\\:");
+ else
+ os << (runparams.free_spacing ? " " : "\\medspace{}");
break;
case InsetSpaceParams::THICK:
- os << (runparams.free_spacing ? " " : "\\;");
+ if (params_.math)
+ os << (runparams.free_spacing ? " " : "\\;");
+ else
+ os << (runparams.free_spacing ? " " : "\\thickspace{}");
break;
case InsetSpaceParams::QUAD:
os << (runparams.free_spacing ? " " : "\\quad{}");
{
switch (params_.kind) {
case InsetSpaceParams::NORMAL:
+ os << " ";
+ break;
case InsetSpaceParams::QUAD:
+ os << " ";
+ break;
case InsetSpaceParams::QQUAD:
+ os << "  ";
+ break;
case InsetSpaceParams::ENSKIP:
- os << " ";
+ os << " ";
break;
- // FIXME For spaces and dashes look here:
- // http://oreilly.com/catalog/docbook/book2/iso-pub.html
case InsetSpaceParams::PROTECTED:
- // FIXME ␣ ?
+ os << " ";
+ break;
case InsetSpaceParams::VISIBLE:
+ os << "␣";
+ break;
case InsetSpaceParams::ENSPACE:
- // FIXME   ?
+ os << "⁠ ⁠";
+ break;
case InsetSpaceParams::THIN:
+ os << " ";
+ break;
case InsetSpaceParams::MEDIUM:
+ os << " ";
+ break;
case InsetSpaceParams::THICK:
+ os << " ";
+ break;
case InsetSpaceParams::NEGTHIN:
case InsetSpaceParams::NEGMEDIUM:
case InsetSpaceParams::NEGTHICK:
+ // FIXME
os << " ";
break;
case InsetSpaceParams::HFILL:
}
-docstring InsetSpace::xhtml(XHTMLStream & xs, OutputParams const &) const
+docstring InsetSpace::xhtml(XMLStream & xs, OutputParams const &) const
{
string output;
switch (params_.kind) {
break;
}
// don't escape the entities!
- xs << XHTMLStream::ESCAPE_NONE << from_ascii(output);
+ xs << XMLStream::ESCAPE_NONE << from_ascii(output);
return docstring();
}
void InsetSpace::validate(LaTeXFeatures & features) const
{
- if (params_.kind == InsetSpaceParams::NEGMEDIUM ||
- params_.kind == InsetSpaceParams::NEGTHICK)
+ if ((params_.kind == InsetSpaceParams::NEGMEDIUM
+ || params_.kind == InsetSpaceParams::NEGTHICK)
+ || (!params_.math
+ && (params_.kind == InsetSpaceParams::MEDIUM
+ || params_.kind == InsetSpaceParams::THICK)))
features.require("amsmath");
}
}
-void InsetSpace::forOutliner(docstring & os, size_t) const
+void InsetSpace::forOutliner(docstring & os, size_t const, bool const) const
{
// There's no need to be cute here.
os += " ";