commit 80f94a9398ef1843d2592e87bd71d1cd2b40703c
Author: Enrico Forestieri <for...@lyx.org>
Date:   Sat Aug 29 20:10:26 2020 +0200

    Use correct width for \fint
    
    Both QTextLine::naturalTextWidth() and QTextLine::horizontalAdvance()
    return the same value for \fint. However, examining esint10.ttf with
    fontforge does not reveal any issue with the metrics. The fact that
    \fint seems to be the only affected symbol might be due to its code
    point, which corresponds to a space, so that maybe Qt makes some
    assumptions on the metrics.
    
    As QTextLine::naturalTextWidth() returns the width of the line that is
    occupied by text, in the case of a single symbol we can obtain the
    same value by using the width of the rectangle bounding the symbol.
---
 src/frontends/qt/GuiFontMetrics.cpp |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/frontends/qt/GuiFontMetrics.cpp 
b/src/frontends/qt/GuiFontMetrics.cpp
index 9ff027e..3611250 100644
--- a/src/frontends/qt/GuiFontMetrics.cpp
+++ b/src/frontends/qt/GuiFontMetrics.cpp
@@ -245,18 +245,18 @@ int GuiFontMetrics::width(docstring const & s) const
 #else
        bool const math_char = s.length() == 1;
 #endif
-       // keep value 0 for math chars with width 0
-       if (!math_char || metrics_.width(toqstr(s)) != 0) {
+       if (math_char) {
+               // keep value 0 for math chars with width 0
+               if (metrics_.width(toqstr(s)) != 0)
+                       w = metrics_.boundingRect(toqstr(s)).width();
+       } else {
                QTextLayout tl;
                tl.setText(toqstr(s));
                tl.setFont(font_);
                tl.beginLayout();
                QTextLine line = tl.createLine();
                tl.endLayout();
-               if (math_char)
-                       w = iround(line.naturalTextWidth());
-               else
-                       w = iround(line.horizontalAdvance());
+               w = iround(line.horizontalAdvance());
        }
        strwidth_cache_.insert(s, w, s.size() * sizeof(char_type));
        return w;
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to