]> git.lyx.org Git - lyx.git/commitdiff
Fix bug #12169
authorRichard Kimberly Heck <rikiheck@lyx.org>
Sat, 27 Feb 2021 18:27:03 +0000 (13:27 -0500)
committerRichard Kimberly Heck <rikiheck@lyx.org>
Sat, 27 Feb 2021 18:27:05 +0000 (13:27 -0500)
Patch from Daniel.

src/frontends/NullPainter.h
src/frontends/Painter.h
src/frontends/qt/GuiPainter.cpp
src/frontends/qt/GuiPainter.h

index c8e214588408d15f4d3e032607fe0976b9df5ff9..3af85aa6b20b108a95eb2ad255e65308c8e78e97 100644 (file)
@@ -105,7 +105,7 @@ public:
        /// leave monochrome painting mode
        void leaveMonochromeMode() override {}
        /// draws a wavy line that can be used for underlining.
-       void wavyHorizontalLine(int, int, int, ColorCode) override {}
+       void wavyHorizontalLine(FontInfo const &, int, int, int, ColorCode) override {}
 };
 
 } // namespace frontend
index 94ee4606c01b7f1f228a699239b46b8fb8897b29..41427ab3e0381bef664ef8039ee7900189a2a060 100644 (file)
@@ -186,7 +186,7 @@ public:
        /// leave monochrome painting mode
        virtual void leaveMonochromeMode() = 0;
        /// draws a wavy line that can be used for underlining.
-       virtual void wavyHorizontalLine(int x, int y, int width, ColorCode col) = 0;
+       virtual void wavyHorizontalLine(FontInfo const & f, int x, int y, int width, ColorCode col) = 0;
 private:
        /// Ratio between physical pixels and device-independent pixels
        double pixel_ratio_;
index 30d7fe3925daecc9bb6f6bf52767ddc9ac48d650..75e9ace9e2541f1d606115b15403c1ddaf39f291 100644 (file)
@@ -406,7 +406,7 @@ void GuiPainter::textDecoration(FontInfo const & f, int x, int y, int width)
                doubleUnderline(f, x, y, width);
        if (f.uwave() == FONT_ON)
                // f.color() doesn't work on some circumstances
-               wavyHorizontalLine(x, y, width,  f.realColor().baseColor);
+               wavyHorizontalLine(f, x, y, width,  f.realColor().baseColor);
 }
 
 
@@ -546,21 +546,28 @@ void GuiPainter::dashedUnderline(FontInfo const & f, int x, int y, int width)
 }
 
 
-void GuiPainter::wavyHorizontalLine(int x, int y, int width, ColorCode col)
+void GuiPainter::wavyHorizontalLine(FontInfo const & f, int x, int y, int width, ColorCode col)
 {
-       setQPainterPen(computeColor(col));
-       int const step = 2;
+       FontMetrics const & fm = theFontMetrics(f);
+       int const pos = fm.underlinePos();
+
+       setQPainterPen(computeColor(col), line_solid, fm.lineWidth());
+       int const step = 2 * fm.lineWidth();
        int const xend = x + width;
-       int height = 1;
+       int height = 1 * fm.lineWidth();
        //FIXME: I am not sure if Antialiasing gives the best effect.
        //setRenderHint(Antialiasing, true);
+       QVector<QPoint> points;
        while (x < xend) {
                height = - height;
-               drawLine(x, y - height, x + step, y + height);
+               points.append(QPoint(x, y + pos - height));
+               points.append(QPoint(x + step, y + pos + height));
                x += step;
-               drawLine(x, y + height, x + step/2, y + height);
+               points.append(QPoint(x, (qreal)y + pos + height));
+               points.append(QPoint(x + step/2, y + pos + height));
                x += step/2;
        }
+       drawPolyline(points);
        //setRenderHint(Antialiasing, false);
 }
 
index b5f61c1dccc49ba1b6f2000e9a2848c36f186c5c..f3b521bcc03777440a50cc4cc2947469c6ff4f30 100644 (file)
@@ -160,7 +160,7 @@ public:
        int preeditText(int x, int y,
                char_type c, FontInfo const & f, preedit_style style) override;
 
-       void wavyHorizontalLine(int x, int y, int width, ColorCode col) override;
+       void wavyHorizontalLine(FontInfo const & f, int x, int y, int width, ColorCode col) override;
 
 private:
        /// check the font, and if set, draw an underline