From 11cfa3be40d2a90b979cf805dc76b49edad01c94 Mon Sep 17 00:00:00 2001 From: pantxo Date: Wed, 9 Oct 2024 22:23:02 +0200 Subject: [PATCH] print: Fix regression in pdf fonts (bug #66306). * octave-svgconvert.cc (draw): Use QFont constructor to set font-family. --- src/octave-svgconvert.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/octave-svgconvert.cc b/src/octave-svgconvert.cc index 1f0d208362..0263c85798 100644 --- a/src/octave-svgconvert.cc +++ b/src/octave-svgconvert.cc @@ -373,8 +373,7 @@ draw (QDomElement& parent_elt, pdfpainter& painter) if (! str.isEmpty ()) { // Font - font = QFont (); - font.setFamily (elt.attribute ("font-family")); + font = QFont (str); str = elt.attribute ("font-weight"); if (! str.isEmpty () && str != "normal") @@ -535,7 +534,14 @@ draw (QDomElement& parent_elt, pdfpainter& painter) QString str = elt.attribute ("font-family"); if (! str.isEmpty ()) - font.setFamily (elt.attribute ("font-family")); + { + // QFont::setFamily() doesn't seem to work properly in Qt6 + // (see bug #66306). Use the QFont constructor to update + // the current font. + font = QFont (str, -1, font.weight (), + font.style () == QFont::StyleItalic); + font.setPixelSize (saved_font.pixelSize ()); + } str = elt.attribute ("font-weight"); if (! str.isEmpty ())