[LyX/master] Adapt quote color to brightened text color (part of #13218)

Juergen Spitzmueller <[email protected]> Thu, 21 May 2026 04:48:09 +0000
Newsgroups gmane.editors.lyx.cvs
Message-ID <[email protected]>
commit 37df97c9d3c9fb7c70736a9017f9cae3cf3a6f6e
Author: Juergen Spitzmueller <[email protected]>
Date:   Thu May 21 06:47:15 2026 +0200

    Adapt quote color to brightened text color (part of #13218)
---
 src/frontends/qt/GuiPainter.cpp |  7 +++----
 src/insets/InsetQuotes.cpp      | 22 ++++++++++++++++++++--
 2 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/src/frontends/qt/GuiPainter.cpp b/src/frontends/qt/GuiPainter.cpp
index 04e9fb9c9e..00ce3205c3 100644
--- a/src/frontends/qt/GuiPainter.cpp
+++ b/src/frontends/qt/GuiPainter.cpp
@@ -330,13 +330,12 @@ void GuiPainter::text(int x, int y, docstring const & s,
 
 	textDecoration(f, x, y, textwidth);
 
-	Color const rc = f.realColor(invert);
-	QColor penColor = computeColor(rc);
+	Color rc = f.realColor(invert);
 	if (invert && rc == f.color())
 		// We are in dark mode and have a dark text color.
 		// Brighten that for workarea display (#13218)
-		penColor = penColor.lighter(170);
-	setQPainterPen(penColor);
+		rc.mergeColor = Color_foreground;
+	setQPainterPen(computeColor(rc));
 	if (dir != Auto) {
 		auto ptl = fm.getTextLayout(s, dir == RtL, wordspacing);
 		QTextLine const & tline = ptl->lineForTextPosition(0);
diff --git a/src/insets/InsetQuotes.cpp b/src/insets/InsetQuotes.cpp
index a68a7598f8..357987025f 100644
--- a/src/insets/InsetQuotes.cpp
+++ b/src/insets/InsetQuotes.cpp
@@ -15,6 +15,7 @@
 
 #include "Buffer.h"
 #include "BufferParams.h"
+#include "ColorSet.h"
 #include "Cursor.h"
 #include "Dimension.h"
 #include "Encoding.h"
@@ -30,6 +31,7 @@
 #include "texstream.h"
 #include "xml.h"
 
+#include "frontends/Application.h"
 #include "frontends/FontMetrics.h"
 #include "frontends/Painter.h"
 
@@ -702,8 +704,24 @@ void InsetQuotes::draw(PainterInfo & pi, int x, int y) const
 	FontInfo font = pi.base.font;
 	if (style_ == QuoteStyle::Dynamic)
 		font.setPaintColor(Color_special);
-	else
-		font.setPaintColor(pi.textColor(font.realColor()));
+	else {
+		bool invert = false;
+		if (theApp() && theApp()->isInDarkMode()) {
+			if (font.color() == Color_none
+			    && theApp()->isLightColor(rgbFromHexName(lcolor.getX11HexName(pi.background_color, true))))
+				invert = true;
+			else if (pi.background_color == Color_background
+				 && font.color() != Color_none
+				 && !theApp()->isLightColor(rgbFromHexName(lcolor.getX11HexName(font.color()))))
+				invert = true;
+		}
+		Color rc = font.realColor(invert);
+		if (invert && rc == font.color())
+			// We are in dark mode and have a dark text color.
+			// Brighten that for workarea display (#13218)
+			rc.mergeColor = Color_foreground;
+		font.setPaintColor(pi.textColor(rc));
+	}
 	pi.pain.text(x, y, displayString(), font);
 }
 
-- 
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs