[education/rkward] /: QPainter does not paint using "Symbol" font

Thomas Friedrichsmeier null at kde.org
Sat Aug 3 22:57:54 BST 2024


Git commit 5cc1dd4de49c1754c411ef8bcd0a92990d8b7357 by Thomas Friedrichsmeier.
Committed on 03/08/2024 at 21:57.
Pushed by tfry into branch 'master'.

QPainter does not paint using "Symbol" font

BUG: 462177

M  +1    -0    ChangeLog
M  +1    -1    rkward/rbackend/rkwarddevice/rkgraphicsdevice_frontendtransmitter.cpp
M  +7    -2    rkward/rbackend/rkwarddevice/rkgraphicsdevice_stubs.cpp

https://invent.kde.org/education/rkward/-/commit/5cc1dd4de49c1754c411ef8bcd0a92990d8b7357

diff --git a/ChangeLog b/ChangeLog
index 31e6b7b1c..1d196d361 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,5 @@
 --- Version 0.8.1 - UNRELEASED
+- Fixed: Failure to paint symbols in onscreen device, under some circumstances
 - Fixed: Potential library conflicts on systems shipping a more recent version of libglib2 than included in the AppImage
 - Fixed: Implement capbilities report for RK() device (may fix graphics limitation, but also potential crashes with R >= 4.2.0)
 - Fixed: Adjustments to changes in R devel (for compatibility with the future R 4.5.x)
diff --git a/rkward/rbackend/rkwarddevice/rkgraphicsdevice_frontendtransmitter.cpp b/rkward/rbackend/rkwarddevice/rkgraphicsdevice_frontendtransmitter.cpp
index c810dc515..d91f72deb 100644
--- a/rkward/rbackend/rkwarddevice/rkgraphicsdevice_frontendtransmitter.cpp
+++ b/rkward/rbackend/rkwarddevice/rkgraphicsdevice_frontendtransmitter.cpp
@@ -198,7 +198,7 @@ static QFont readFont (QDataStream &instream) {
 #	warning TODO deal with line-height
 #endif
 	QFont ret;
-	if (!fontfamily.isEmpty()) ret.setFamily(fontfamily);
+	if (!(fontfamily.isEmpty() || fontfamily == "Symbol")) ret.setFamily(fontfamily); // NOTE: QPainter won't paint with "Symbol", somehow
 	if (fontface == 2 || fontface == 4) ret.setWeight (QFont::Bold);
 	if (fontface == 3 || fontface == 4) ret.setItalic (true);
 	ret.setPointSizeF (cex*ps);
diff --git a/rkward/rbackend/rkwarddevice/rkgraphicsdevice_stubs.cpp b/rkward/rbackend/rkwarddevice/rkgraphicsdevice_stubs.cpp
index 3b513b97a..5b54ab940 100644
--- a/rkward/rbackend/rkwarddevice/rkgraphicsdevice_stubs.cpp
+++ b/rkward/rbackend/rkwarddevice/rkgraphicsdevice_stubs.cpp
@@ -383,8 +383,13 @@ static void RKD_MetricInfo (int c, R_GE_gcontext *gc, double* ascent, double* de
 		RKGraphicsDataStreamWriteGuard wguard;
 		WRITE_HEADER (RKDMetricInfo, dev);
 		QChar unichar;
-		if (c < 0) unichar = QChar (-c);
-		else {		// correct?! Do we get utf8, here?
+		if (c < 0) {
+			char32_t inbuf[2];
+			inbuf[0] = -c;
+			inbuf[1] = 0;
+			QString dummy = QString::fromUcs4(inbuf);
+			if (!dummy.isEmpty ()) unichar = dummy.at (0);
+		} else {		// correct?! Do we get utf8, here?
 			int inbuf[2];
 			inbuf[0] = c;
 			inbuf[1] = 0;


More information about the rkward-tracker mailing list