X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Finsets%2FInsetSpace.cpp;h=7d76f3f62ea0a4dfb2c0bb9fec2c4bbb667ff892;hb=858f6b6c7b630f7672001fb19b55109a89aed142;hp=5720731693fbcf221c0990990bc8f425eb4debf9;hpb=8c3829e6f155a4b78897e99f363bd575da1667e1;p=lyx.git diff --git a/src/insets/InsetSpace.cpp b/src/insets/InsetSpace.cpp index 5720731693..7d76f3f62e 100644 --- a/src/insets/InsetSpace.cpp +++ b/src/insets/InsetSpace.cpp @@ -27,6 +27,7 @@ #include "MetricsInfo.h" #include "OutputParams.h" #include "output_xhtml.h" +#include "texstream.h" #include "support/debug.h" #include "support/docstream.h" @@ -200,28 +201,30 @@ 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::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: @@ -229,20 +232,19 @@ void InsetSpace::metrics(MetricsInfo & mi, Dimension & dim) const 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'))); + params_.length.len().inPixels(mi.base); int const minw = (w < 0) ? 3 * arrow_size : 4; dim.wid = max(minw, abs(w)); break; @@ -387,7 +389,6 @@ void InsetSpace::draw(PainterInfo & pi, int x, int y) const void InsetSpaceParams::write(ostream & os) const { - string command; switch (kind) { case InsetSpaceParams::NORMAL: os << "\\space{}"; @@ -706,13 +707,13 @@ int InsetSpace::docbook(odocstream & os, OutputParams const &) const os << " "; break; case InsetSpaceParams::QUAD: - os << " " + os << " "; break; case InsetSpaceParams::QQUAD: - os << "  " + os << "  "; break; case InsetSpaceParams::ENSKIP: - os << " " + os << " "; break; case InsetSpaceParams::PROTECTED: os << " "; @@ -845,7 +846,7 @@ void InsetSpace::toString(odocstream & os) const } -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 += " ";