* InsetNomencl.cpp (nomenclWidest):

- use FontMetrics to determine widest string.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29776 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Spitzmüller 2009-05-22 09:25:31 +00:00
parent 18cfe15b64
commit 72ae399fad

View File

@ -17,6 +17,7 @@
#include "Buffer.h"
#include "DispatchResult.h"
#include "Font.h"
#include "FuncRequest.h"
#include "InsetIterator.h"
#include "InsetList.h"
@ -24,6 +25,8 @@
#include "MetricsInfo.h"
#include "sgml.h"
#include "frontends/FontMetrics.h"
#include "support/docstream.h"
#include "support/gettext.h"
#include "support/lstrings.h"
@ -190,19 +193,19 @@ docstring nomenclWidest(Buffer const & buffer)
if (inset->lyxCode() != NOMENCL_CODE)
continue;
nomencl = static_cast<InsetNomencl const *>(inset);
docstring const symbol = nomencl->getParam("symbol");
// we can only check for the number of characters, since it is
// impossible to get the info that "iiiii" is smaller than "WW"
// we therefore output w times "W" as string ("W" is always the
// widest character)
int const wx = symbol.size();
if (wx > w)
docstring const symbol =
nomencl->getParam("symbol");
// This is only an approximation,
// but the best we can get.
int const wx =
theFontMetrics(Font()).width(symbol);
if (wx > w) {
w = wx;
symb = symbol;
}
}
}
// return the widest symbol as w times a "W"
for (int n = 1; n <= w; ++n)
symb = symb + "W";
// return the widest (or an empty) string
return symb;
}
}
@ -219,6 +222,7 @@ int InsetPrintNomencl::latex(odocstream & os, OutputParams const &) const
if (!widest.empty()) {
// assure that the width is never below the
// predefined value of 1 cm
// FIXME: Why this?
os << "\\settowidth{\\nomlabelwidth}{"
<< widest
<< "}\n";