]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiPainter.cpp
Remove a redundant deletion of a QObject
[lyx.git] / src / frontends / qt4 / GuiPainter.cpp
index 5762c9b958ab42e49e3e31c494b07bbbcd37fd07..448b5a44b23f6231b6672feb8144a48cb08dd43e 100644 (file)
@@ -213,7 +213,9 @@ void GuiPainter::lines(int const * xp, int const * yp, int np,
        if (np > points.size())
                points.resize(2 * np);
 
-       bool antialias = ls != line_solid_aliased;
+       // Note: the proper way to not get blurry vertical and horizontal lines is
+       // to add 0.5 to all coordinates.
+       bool antialias = false;
        for (int i = 0; i < np; ++i) {
                points[i].setX(xp[i]);
                points[i].setY(yp[i]);
@@ -223,7 +225,8 @@ void GuiPainter::lines(int const * xp, int const * yp, int np,
        QColor const color = computeColor(col);
        setQPainterPen(color, ls, lw);
        bool const text_is_antialiased = renderHints() & TextAntialiasing;
-       setRenderHint(Antialiasing, antialias && text_is_antialiased);
+       setRenderHint(Antialiasing,
+                     antialias && text_is_antialiased && ls != line_solid_aliased);
        if (fs == fill_none) {
                drawPolyline(points.data(), np);
        } else {
@@ -420,7 +423,8 @@ void GuiPainter::text(int x, int y, docstring const & s,
        int textwidth = 0;
        if (tw == 0.0)
                // Note that we have to take in account space stretching (word spacing)
-               textwidth = fm.width(s) + count(s.begin(), s.end(), ' ') * wordspacing;
+               textwidth = fm.width(s) +
+                       static_cast<int>(fm.countExpanders(s) * wordspacing);
        else
                textwidth = static_cast<int>(tw);
 
@@ -474,8 +478,17 @@ void GuiPainter::text(int x, int y, docstring const & s,
                return;
        }
 
-       // don't use the pixmap cache,
-       do_drawText(x, y, str, dir, f, ff);
+       // don't use the pixmap cache
+       setQPainterPen(computeColor(f.realColor()));
+       if (dir != Auto) {
+               QTextLayout const * ptl = fm.getTextLayout(s, dir == RtL, wordspacing);
+               ptl->draw(this, QPointF(x, y - fm.maxAscent()));
+       }
+       else {
+               if (font() != ff)
+                       setFont(ff);
+               drawText(x, y, str);
+       }
        //LYXERR(Debug::PAINTING, "draw " << string(str.toUtf8())
        //      << " at " << x << "," << y);
 }