]> git.lyx.org Git - lyx.git/commitdiff
Improve calculation of longest nomencl string
authorJuergen Spitzmueller <spitz@lyx.org>
Sat, 20 Jul 2024 15:38:36 +0000 (17:38 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Sat, 20 Jul 2024 15:39:58 +0000 (17:39 +0200)
This tries o convert LaTeX macros before estimating the length

src/insets/InsetNomencl.cpp

index 1d2ceb33181749c8b8dd23f451687f8541abcaac..da628442cd09b3cb704d0c3c9f8d416c7c073a04 100644 (file)
@@ -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;