[LyX/master] #12769 correct line width based painting of wavy underline

Stephan Witt switt at lyx.org
Mon May 15 03:58:42 UTC 2023


commit ac286e54b7dcdd7fdde46359e1b859e0c1ba54f7
Author: Stephan Witt <switt at lyx.org>
Date:   Mon May 15 07:06:44 2023 +0200

    #12769 correct line width based painting of wavy underline
    
    With very tiny fonts the line width is 0 and the loop to construct the wavy line never ends.
---
 src/frontends/qt/GuiPainter.cpp |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/frontends/qt/GuiPainter.cpp b/src/frontends/qt/GuiPainter.cpp
index a64d006..62e48c4 100644
--- a/src/frontends/qt/GuiPainter.cpp
+++ b/src/frontends/qt/GuiPainter.cpp
@@ -546,11 +546,12 @@ void GuiPainter::wavyHorizontalLine(FontInfo const & f, int x, int y, int width,
 {
 	FontMetrics const & fm = theFontMetrics(f);
 	int const pos = fm.underlinePos();
+	int const lw = max(1, fm.lineWidth());
 
-	setQPainterPen(computeColor(col), line_solid, fm.lineWidth());
-	int const step = 2 * fm.lineWidth();
+	setQPainterPen(computeColor(col), line_solid, lw);
+	int const step = 2 * lw;
 	int const xend = x + width;
-	int height = 1 * fm.lineWidth();
+	int height = lw;
 	//FIXME: I am not sure if Antialiasing gives the best effect.
 	//setRenderHint(Antialiasing, true);
 	QVector<QPoint> points;
@@ -560,8 +561,8 @@ void GuiPainter::wavyHorizontalLine(FontInfo const & f, int x, int y, int width,
 		points.append(QPoint(x + step, y + pos + height));
 		x += step;
 		points.append(QPoint(x, (qreal)y + pos + height));
-		points.append(QPoint(x + step/2, y + pos + height));
-		x += step/2;
+		points.append(QPoint(x + lw, y + pos + height));
+		x += lw;
 	}
 	drawPolyline(points);
 	//setRenderHint(Antialiasing, false);


More information about the lyx-cvs mailing list