void InsetSpace::metrics(MetricsInfo & mi, Dimension & dim) const
{
- if (isStretchableSpace()) {
- // The metrics for this kinds are calculated externally in
- // \c TextMetrics::computeRowMetrics. Those are dummy value:
- dim = Dimension(10, 10, 10);
+ if (isHfill()) {
+ // The width for hfills is calculated externally in
+ // TextMetrics::computeRowMetrics. 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 =
+ params_.length.len().inPixels(mi.base);
int const minw = (w < 0) ? 3 * arrow_size : 4;
dim.wid = max(minw, abs(w));
break;
{
Dimension const dim = dimension(*pi.base.bv);
- if (isStretchableSpace() || params_.length.len().value() < 0) {
+ if (isHfill() || params_.length.len().value() < 0) {
int const asc = theFontMetrics(pi.base.font).ascent('M');
int const desc = theFontMetrics(pi.base.font).descent('M');
// Pixel height divisible by 2 for prettier fill graphics:
void InsetSpaceParams::write(ostream & os) const
{
- string command;
switch (kind) {
case InsetSpaceParams::NORMAL:
os << "\\space{}";
os << "\\hspace*{}";
break;
}
-
+
if (!length.len().empty())
os << "\n\\length " << length.asString();
}
{
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:
}
-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 += " ";
}
-bool InsetSpace::isStretchableSpace() const
+bool InsetSpace::isHfill() const
{
return params_.kind == InsetSpaceParams::HFILL
|| params_.kind == InsetSpaceParams::HFILL_PROTECTED