mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
* 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:
parent
18cfe15b64
commit
72ae399fad
@ -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";
|
||||
|
Loading…
Reference in New Issue
Block a user