]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiPainter.cpp
Use <cstdint> instead of <boost/cstdint.hpp>
[lyx.git] / src / frontends / qt4 / GuiPainter.cpp
index 8bd9efbe178ff5a5facd73e1debe0b42f18ed7c9..c1f3677815f26b646f49b1e4ceda2b04356717b2 100644 (file)
@@ -329,7 +329,8 @@ void GuiPainter::text(int x, int y, docstring const & s,
        setQPainterPen(computeColor(f.realColor()));
        if (dir != Auto) {
                auto ptl = fm.getTextLayout(s, dir == RtL, wordspacing);
-               ptl->draw(this, QPointF(x, y - fm.maxAscent()));
+               QTextLine const & tline = ptl->lineForTextPosition(0);
+               ptl->draw(this, QPointF(x, y - tline.ascent()));
        } else {
                if (font() != ff)
                        setFont(ff);
@@ -361,7 +362,11 @@ void GuiPainter::text(int x, int y, docstring const & str, Font const & f,
        int const height = fm.maxAscent() + fm.maxDescent();
        int xmin = fm.pos2x(str, from, dir == RtL, wordspacing);
        int xmax = fm.pos2x(str, to, dir == RtL, wordspacing);
-       if (xmin > xmax)
+       // Avoid this case, since it would make the `other' text spill in some cases
+       if (xmin == xmax) {
+               text(x, y, str, fi, dir, wordspacing, tw);
+               return;
+       } else if (xmin > xmax)
                swap(xmin, xmax);
 
        // First the part in other color