[LyX/master] Improve calculation of longest nomencl string
Juergen Spitzmueller
spitz at lyx.org
Sat Jul 20 15:40:36 UTC 2024
commit d62f1723a5cb486d2efbf6c19eba238cc954a4f1
Author: Juergen Spitzmueller <spitz at lyx.org>
Date: Sat Jul 20 17:38:36 2024 +0200
Improve calculation of longest nomencl string
This tries o convert LaTeX macros before estimating the length
---
src/insets/InsetNomencl.cpp | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/insets/InsetNomencl.cpp b/src/insets/InsetNomencl.cpp
index 1d2ceb3318..da628442cd 100644
--- a/src/insets/InsetNomencl.cpp
+++ b/src/insets/InsetNomencl.cpp
@@ -400,11 +400,15 @@ docstring nomenclWidest(Buffer const & buffer, OutputParams const & runparams)
// strip out % characters which are used as escape in nomencl
// but act as comment in our context here
symbol = subst(symbol, from_ascii("%"), docstring());
+ // for measurement, convert to a somewhat more output-like string
+ docstring msymb = Encodings::convertLaTeXCommands(symbol);
// This is only an approximation,
// but the best we can get.
+ // FIXME: this might produce different results with
+ // and without GUI (#10634)
int const wx = use_gui ?
- theFontMetrics(Font()).width(symbol) :
- symbol.size();
+ theFontMetrics(Font()).width(msymb) :
+ msymb.size();
if (wx > w) {
w = wx;
symb = symbol;
More information about the lyx-cvs
mailing list