r24308 by jghali - #16379 : Fix several issues of low quality display in font combos, font preview, print preview, output preview

scribus-commit scribus-commit at lists.scribus.net
Mon Dec 7 18:30:46 UTC 2020


Author: jghali
Date: Mon Dec  7 18:30:46 2020
New Revision: 24308

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=24308
Log:
#16379 : Fix several issues of low quality display in font combos, font preview, print preview, output preview

Modified:
    trunk/Scribus/scribus/plugins/colorwheel/cwdialog.cpp
    trunk/Scribus/scribus/plugins/fontpreview/fontpreview.cpp
    trunk/Scribus/scribus/printpreviewcreator.cpp
    trunk/Scribus/scribus/printpreviewcreator.h
    trunk/Scribus/scribus/printpreviewcreator_gdi.cpp
    trunk/Scribus/scribus/printpreviewcreator_pdf.cpp
    trunk/Scribus/scribus/printpreviewcreator_ps.cpp
    trunk/Scribus/scribus/sampleitem.cpp
    trunk/Scribus/scribus/sampleitem.h
    trunk/Scribus/scribus/ui/arcwidget.cpp
    trunk/Scribus/scribus/ui/fontcombo.cpp
    trunk/Scribus/scribus/ui/outputpreview_pdf.cpp
    trunk/Scribus/scribus/ui/outputpreview_ps.cpp
    trunk/Scribus/scribus/ui/polygonwidget.cpp
    trunk/Scribus/scribus/ui/prefs_itemtools.cpp
    trunk/Scribus/scribus/ui/printpreview.cpp
    trunk/Scribus/scribus/ui/spiralwidget.cpp

Modified: trunk/Scribus/scribus/plugins/colorwheel/cwdialog.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24308&path=/trunk/Scribus/scribus/plugins/colorwheel/cwdialog.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/colorwheel/cwdialog.cpp	(original)
+++ trunk/Scribus/scribus/plugins/colorwheel/cwdialog.cpp	Mon Dec  7 18:30:46 2020
@@ -255,7 +255,8 @@
 	int y = previewLabel->height();
 	QList<ScColor> cols = colorWheel->colorList.values();
 	int xstep = x / cols.count();
-	QPixmap pm = QPixmap(x, y);
+	QPixmap pm = QPixmap(x * devicePixelRatioF(), y * devicePixelRatioF());
+	pm.setDevicePixelRatio(devicePixelRatioF());
 	QPainter *p = new QPainter(&pm);
 	QFontMetrics fm = p->fontMetrics();
 

Modified: trunk/Scribus/scribus/plugins/fontpreview/fontpreview.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24308&path=/trunk/Scribus/scribus/plugins/fontpreview/fontpreview.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fontpreview/fontpreview.cpp	(original)
+++ trunk/Scribus/scribus/plugins/fontpreview/fontpreview.cpp	Mon Dec  7 18:30:46 2020
@@ -24,9 +24,10 @@
 	setupUi(this);
 	setModal(true);
 	setWindowIcon(IconManager::instance().loadIcon("AppIcon.png"));
-	m_Doc=doc;
+	m_Doc = doc;
 
 	sampleItem = new SampleItem();
+	sampleItem->setDevicePixelRatio(devicePixelRatioF());
 
 	languageChange();
 
@@ -46,7 +47,7 @@
 	uint srt = prefs->getUInt("sortColumn", 0);
 	bool extend = prefs->getBool("extendedView", false);
 	extendedCheckBox->setChecked(extend);
-	Qt::SortOrder srtOrder = (Qt::SortOrder)prefs->getUInt("sortColumnOrder", 0);
+	Qt::SortOrder srtOrder = (Qt::SortOrder) prefs->getUInt("sortColumnOrder", 0);
 
 	proxyModel->sort(srt, srtOrder);
 	fontList->horizontalHeader()->setSortIndicatorShown(true);

Modified: trunk/Scribus/scribus/printpreviewcreator.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24308&path=/trunk/Scribus/scribus/printpreviewcreator.cpp
==============================================================================
--- trunk/Scribus/scribus/printpreviewcreator.cpp	(original)
+++ trunk/Scribus/scribus/printpreviewcreator.cpp	Mon Dec  7 18:30:46 2020
@@ -38,6 +38,14 @@
 	if (m_useAntialiasing == enabled)
 		return;
 	m_useAntialiasing = enabled;
+	m_renderingOptionsChanged = true;
+}
+
+void PrintPreviewCreator::setDevicePixelRatio(double ratio)
+{
+	if (m_devicePixelRatio == ratio)
+		return;
+	m_devicePixelRatio = ratio;
 	m_renderingOptionsChanged = true;
 }
 

Modified: trunk/Scribus/scribus/printpreviewcreator.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24308&path=/trunk/Scribus/scribus/printpreviewcreator.h
==============================================================================
--- trunk/Scribus/scribus/printpreviewcreator.h	(original)
+++ trunk/Scribus/scribus/printpreviewcreator.h	Mon Dec  7 18:30:46 2020
@@ -57,6 +57,11 @@
 	virtual void setAntialisingEnabled(bool enabled);
 
 	/**
+	* @brief Set device pixel ratio
+	*/
+	virtual void setDevicePixelRatio(double ratio);
+
+	/**
 	 * @brief Set preview resolution (in dot per inch)
 	 */
 	virtual void setPreviewResolution(int res);
@@ -79,6 +84,8 @@
 protected:
 	ScribusDoc* m_doc { nullptr };
 	PrintOptions m_printOptions;
+
+	double m_devicePixelRatio { 1.0 };
 
 	int  m_previewResolution { 72 };
 	bool m_useAntialiasing { true };

Modified: trunk/Scribus/scribus/printpreviewcreator_gdi.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24308&path=/trunk/Scribus/scribus/printpreviewcreator_gdi.cpp
==============================================================================
--- trunk/Scribus/scribus/printpreviewcreator_gdi.cpp	(original)
+++ trunk/Scribus/scribus/printpreviewcreator_gdi.cpp	Mon Dec  7 18:30:46 2020
@@ -86,9 +86,12 @@
 	const ScPage* page = m_doc->Pages->at(pageIndex);
 	if ((page->orientation() == 1) && (image.width() < image.height()))
 		image = image.transformed( QTransform(0, 1, -1, 0, 0, 0) );
+
+	image.setDevicePixelRatio(m_devicePixelRatio);
 	if (m_showTransparency)
 	{
 		pixmap = QPixmap(image.width(), image.height());
+		pixmap.setDevicePixelRatio(m_devicePixelRatio);
 		QPainter p;
 		QBrush b(QColor(205,205,205), IconManager::instance().loadPixmap("testfill.png"));
 		p.begin(&pixmap);
@@ -98,6 +101,8 @@
 	}
 	else
 		pixmap = QPixmap::fromImage(image);
+	pixmap.setDevicePixelRatio(m_devicePixelRatio);
+
 	return pixmap;
 }
 
@@ -118,7 +123,7 @@
 	options.toFile = false;
 	options.useColor = m_printOptions.useColor;
 	options.useSpotColors = false;
-	bool done = winPrint.gdiPrintPreview(page, &image, options, res / 72.0);
+	bool done = winPrint.gdiPrintPreview(page, &image, options, res / 72.0 * m_devicePixelRatio);
 	if (done)
 		image.save( ScPaths::tempFileDir() + m_tempBaseName + ".png", "PNG" );
 	return done;

Modified: trunk/Scribus/scribus/printpreviewcreator_pdf.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24308&path=/trunk/Scribus/scribus/printpreviewcreator_pdf.cpp
==============================================================================
--- trunk/Scribus/scribus/printpreviewcreator_pdf.cpp	(original)
+++ trunk/Scribus/scribus/printpreviewcreator_pdf.cpp	Mon Dec  7 18:30:46 2020
@@ -74,8 +74,9 @@
 QPixmap PrintPreviewCreator_PDF::createPreview(int pageIndex)
 {
 	int ret = -1;
-	double w = m_doc->Pages->at(pageIndex)->width() * m_previewResolution / 72.0;
-	double h = m_doc->Pages->at(pageIndex)->height() * m_previewResolution / 72.0;
+	int gsRes = qRound(m_previewResolution * m_devicePixelRatio);
+	int w = qRound(m_doc->Pages->at(pageIndex)->width() * gsRes / 72.0);
+	int h = qRound(m_doc->Pages->at(pageIndex)->height() * gsRes / 72.0);
 
 	QPixmap pixmap;
 	if (m_printOptionsChanged || (m_pageIndex != pageIndex))
@@ -91,9 +92,9 @@
 	if (m_printOptionsChanged || m_renderingOptionsChanged || (m_pageIndex != pageIndex))
 	{
 		if (m_sepPreviewEnabled && m_haveTiffSep)
-			ret = renderPreviewSep(pageIndex, m_previewResolution);
+			ret = renderPreviewSep(pageIndex, gsRes);
 		else
-			ret = renderPreview(pageIndex, m_previewResolution);
+			ret = renderPreview(pageIndex, gsRes);
 		if (ret > 0)
 		{
 			imageLoadError(pixmap, pageIndex);
@@ -109,8 +110,8 @@
 
 		ScImage im;
 		bool mode;
-		int w2 = qRound(w);
-		int h2 = qRound(h);
+		int w2 = w;
+		int h2 = h;
 		image = QImage(w2, h2, QImage::Format_ARGB32);
 		image.fill(qRgba(0, 0, 0, 0));
 		
@@ -306,9 +307,11 @@
 		}
 	}
 
+	image.setDevicePixelRatio(m_devicePixelRatio);
 	if (m_showTransparency)
 	{
 		pixmap = QPixmap(image.width(), image.height());
+		pixmap.setDevicePixelRatio(m_devicePixelRatio);
 		QPainter p;
 		QBrush b(QColor(205,205,205), IconManager::instance().loadPixmap("testfill.png"));
 		p.begin(&pixmap);
@@ -318,6 +321,7 @@
 	}
 	else
 		pixmap = QPixmap::fromImage(image);
+	pixmap.setDevicePixelRatio(m_devicePixelRatio);
 
 	m_pageIndex = pageIndex;
 	m_printOptionsChanged = false;
@@ -361,14 +365,14 @@
 
 	QStringList args;
 	QString tmp, tmp2, tmp3;
-	double w = m_doc->Pages->at(pageIndex)->width() * res / 72.0;
-	double h = m_doc->Pages->at(pageIndex)->height() * res / 72.0;
+	int w = qRound(m_doc->Pages->at(pageIndex)->width() * res / 72.0);
+	int h = qRound(m_doc->Pages->at(pageIndex)->height() * res / 72.0);
 
 	args.append( "-q" );
 	args.append( "-dNOPAUSE" );
 	args.append( "-dPARANOIDSAFER" );
 	args.append( QString("-r%1").arg(tmp.setNum(res)) );
-	args.append( QString("-g%1x%2").arg(tmp2.setNum(qRound(w)), tmp3.setNum(qRound(h))) );
+	args.append( QString("-g%1x%2").arg(tmp2.setNum(w), tmp3.setNum(h)) );
 	if (m_sepPreviewEnabled)
 	{
 		if (!m_haveTiffSep)
@@ -439,14 +443,14 @@
 	QStringList args, args1, args2, args3;
 
 	QString tmp, tmp2, tmp3;
-	double w = m_doc->Pages->at(pageIndex)->width() * res / 72.0;
-	double h = m_doc->Pages->at(pageIndex)->height() * res / 72.0;
+	int w = qRound(m_doc->Pages->at(pageIndex)->width() * res / 72.0);
+	int h = qRound(m_doc->Pages->at(pageIndex)->height() * res / 72.0);
 
 	args1.append( "-q" );
 	args1.append( "-dNOPAUSE" );
 	args1.append( "-dPARANOIDSAFER" );
 	args1.append( QString("-r%1").arg(tmp.setNum(res)) );
-	args1.append( QString("-g%1x%2").arg(tmp2.setNum(qRound(w)), tmp3.setNum(qRound(h))) );
+	args1.append( QString("-g%1x%2").arg(tmp2.setNum(w), tmp3.setNum(h)) );
 	if (m_useAntialiasing)
 	{
 		args1.append("-dTextAlphaBits=4");

Modified: trunk/Scribus/scribus/printpreviewcreator_ps.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24308&path=/trunk/Scribus/scribus/printpreviewcreator_ps.cpp
==============================================================================
--- trunk/Scribus/scribus/printpreviewcreator_ps.cpp	(original)
+++ trunk/Scribus/scribus/printpreviewcreator_ps.cpp	Mon Dec  7 18:30:46 2020
@@ -68,8 +68,9 @@
 QPixmap PrintPreviewCreator_PS::createPreview(int pageIndex)
 {
 	int ret = -1;
-	double w = m_doc->Pages->at(pageIndex)->width() * m_previewResolution / 72.0;
-	double h = m_doc->Pages->at(pageIndex)->height() * m_previewResolution / 72.0;
+	int gsRes = qRound(m_previewResolution * m_devicePixelRatio);
+	int w = qRound(m_doc->Pages->at(pageIndex)->width() * gsRes / 72.0);
+	int h = qRound(m_doc->Pages->at(pageIndex)->height() * gsRes / 72.0);
 
 	QPixmap pixmap;
 	if (m_printOptionsChanged || (m_pageIndex != pageIndex))
@@ -85,9 +86,9 @@
 	if (m_printOptionsChanged || m_renderingOptionsChanged || (m_pageIndex != pageIndex))
 	{
 		if (m_sepPreviewEnabled && m_haveTiffSep)
-			ret = renderPreviewSep(pageIndex, m_previewResolution);
+			ret = renderPreviewSep(pageIndex, gsRes);
 		else
-			ret = renderPreview(pageIndex, m_previewResolution);
+			ret = renderPreview(pageIndex, gsRes);
 		if (ret > 0)
 		{
 			imageLoadError(pixmap, pageIndex);
@@ -103,8 +104,8 @@
 
 		ScImage im;
 		bool mode;
-		int w2 = qRound(w);
-		int h2 = qRound(h);
+		int w2 = w;
+		int h2 = h;
 		if (m_doc->Pages->at(pageIndex)->orientation() == 1)
 			std::swap(w2, h2);
 		image = QImage(w2, h2, QImage::Format_ARGB32);
@@ -305,9 +306,12 @@
 	const ScPage* page = m_doc->Pages->at(pageIndex);
 	if ((page->orientation() == 1) && (image.width() < image.height()))
 		image = image.transformed( QTransform(0, 1, -1, 0, 0, 0) );
+
+	image.setDevicePixelRatio(m_devicePixelRatio);
 	if (m_showTransparency)
 	{
 		pixmap = QPixmap(image.width(), image.height());
+		pixmap.setDevicePixelRatio(m_devicePixelRatio);
 		QPainter p;
 		QBrush b(QColor(205,205,205), IconManager::instance().loadPixmap("testfill.png"));
 		p.begin(&pixmap);
@@ -317,6 +321,7 @@
 	}
 	else
 		pixmap = QPixmap::fromImage(image);
+	pixmap.setDevicePixelRatio(m_devicePixelRatio);
 
 	m_pageIndex = pageIndex;
 	m_printOptionsChanged = false;
@@ -385,8 +390,8 @@
 
 	QStringList args;
 	QString tmp, tmp2, tmp3;
-	double w = m_doc->Pages->at(pageIndex)->width() * res / 72.0;
-	double h = m_doc->Pages->at(pageIndex)->height() * res / 72.0;
+	int w = qRound(m_doc->Pages->at(pageIndex)->width() * res / 72.0);
+	int h = qRound(m_doc->Pages->at(pageIndex)->height() * res / 72.0);
 	if (m_doc->Pages->at(pageIndex)->orientation() == 1)
 		std::swap(w, h);
 
@@ -394,7 +399,7 @@
 	args.append( "-dNOPAUSE" );
 	args.append( "-dPARANOIDSAFER" );
 	args.append( QString("-r%1").arg(tmp.setNum(res)) );
-	args.append( QString("-g%1x%2").arg(tmp2.setNum(qRound(w)), tmp3.setNum(qRound(h))) );
+	args.append( QString("-g%1x%2").arg(tmp2.setNum(w), tmp3.setNum(h)) );
 	if (m_sepPreviewEnabled)
 	{
 		if (!m_haveTiffSep)
@@ -465,8 +470,8 @@
 	QStringList args, args1, args2, args3;
 
 	QString tmp, tmp2, tmp3;
-	double w = m_doc->Pages->at(pageIndex)->width() * res / 72.0;
-	double h = m_doc->Pages->at(pageIndex)->height() * res / 72.0;
+	int w = qRound(m_doc->Pages->at(pageIndex)->width() * res / 72.0);
+	int h = qRound(m_doc->Pages->at(pageIndex)->height() * res / 72.0);
 	if (m_doc->Pages->at(pageIndex)->orientation() == 1)
 		std::swap(w, h);
 
@@ -474,7 +479,7 @@
 	args1.append( "-dNOPAUSE" );
 	args1.append( "-dPARANOIDSAFER" );
 	args1.append( QString("-r%1").arg(tmp.setNum(res)) );
-	args1.append( QString("-g%1x%2").arg(tmp2.setNum(qRound(w)), tmp3.setNum(qRound(h))) );
+	args1.append( QString("-g%1x%2").arg(tmp2.setNum(w), tmp3.setNum(h)) );
 	if (m_useAntialiasing)
 	{
 		args1.append("-dTextAlphaBits=4");

Modified: trunk/Scribus/scribus/sampleitem.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24308&path=/trunk/Scribus/scribus/sampleitem.cpp
==============================================================================
--- trunk/Scribus/scribus/sampleitem.cpp	(original)
+++ trunk/Scribus/scribus/sampleitem.cpp	Mon Dec  7 18:30:46 2020
@@ -290,12 +290,17 @@
 
 	UndoManager::instance()->setUndoEnabled(false); // disable undo
 
+	int pmWidth = qRound(width * m_devicePixelRatio);
+	int pmHeight = qRound(height * m_devicePixelRatio);
 	double frameWidth  = width / PrefsManager::instance().appPrefs.displayPrefs.displayScale;
 	double frameHeight = height / PrefsManager::instance().appPrefs.displayPrefs.displayScale;
 
 	PageItem_TextFrame *previewItem = new PageItem_TextFrame(m_Doc, 0, 0, frameWidth, frameHeight, 0, "__whiteforpreviewbg__", "__whiteforpreview__");
-	QImage pm(width, height, QImage::Format_ARGB32);
-	ScPainter *painter = new ScPainter(&pm, width, height, 1.0, 0);
+	
+	QImage pm(pmWidth, pmHeight, QImage::Format_ARGB32);
+	pm.setDevicePixelRatio(m_devicePixelRatio);
+
+	ScPainter *painter = new ScPainter(&pm, pmWidth, pmHeight, 1.0, 0);
 	painter->setZoomFactor(PrefsManager::instance().appPrefs.displayPrefs.displayScale);
 
 	if (m_Doc->UsedFonts.contains(m_tmpStyle.charStyle().font().scName()))
@@ -328,5 +333,7 @@
 	}
 //	m_Doc->docParagraphStyles.remove(tmpIndex);
 	UndoManager::instance()->setUndoEnabled(true);
-	return QPixmap::fromImage(pm);
-}
+
+	QPixmap pixmap = QPixmap::fromImage(pm);
+	return pixmap;
+}

Modified: trunk/Scribus/scribus/sampleitem.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24308&path=/trunk/Scribus/scribus/sampleitem.h
==============================================================================
--- trunk/Scribus/scribus/sampleitem.h	(original)
+++ trunk/Scribus/scribus/sampleitem.h	Mon Dec  7 18:30:46 2020
@@ -29,6 +29,9 @@
 	public:
 		SampleItem();
 		~SampleItem();
+
+		/*! \brief Set device pixel ratio */
+		void setDevicePixelRatio(double ratio) { m_devicePixelRatio = ratio; }
 
 		/*! \brief Set sample text.
 		\param aText QString to set. */
@@ -106,6 +109,8 @@
 		ScribusDoc *m_Doc;
 		//! \brief Is the doc created used only? true = used
 		int m_bgShade;
+		//! \brief Device pixel ratio
+		double m_devicePixelRatio { 1.0 };
 };
 
 #endif

Modified: trunk/Scribus/scribus/ui/arcwidget.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24308&path=/trunk/Scribus/scribus/ui/arcwidget.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/arcwidget.cpp	(original)
+++ trunk/Scribus/scribus/ui/arcwidget.cpp	Mon Dec  7 18:30:46 2020
@@ -63,20 +63,29 @@
 
 void ArcWidget::updatePreview()
 {
-	QPixmap pm = QPixmap(Preview->width() - 5, Preview->height() - 5);
+	int arcWidth = Preview->width() - 11;
+	int arcHeight = Preview->height() - 11;
+	int pixWidth = Preview->width() - 5;
+	int pixHeight = Preview->height() - 5;
+
+	QPixmap pm = QPixmap(pixWidth * devicePixelRatioF(), pixHeight * devicePixelRatioF());
+	pm.setDevicePixelRatio(devicePixelRatioF());
 	pm.fill(Qt::white);
+
 	QPainter p;
 	p.begin(&pm);
+	p.setRenderHint(QPainter::Antialiasing, true);
 	p.setBrush(Qt::NoBrush);
 	p.setPen(Qt::black);
 	QPainterPath path;
-	path.moveTo(pm.width() / 2.0, pm.height() / 2.0);
+	path.moveTo(pixWidth / 2.0, pixHeight / 2.0);
 	double nSweep = endAngle->value() - startAngle->value();
 	if (nSweep < 0)
 		nSweep += 360;
-	path.arcTo(3.0, 3.0, pm.width() - 6, pm.height() - 6, startAngle->value(), nSweep);
+	path.arcTo(3.0, 3.0, arcWidth, arcHeight, startAngle->value(), nSweep);
 	path.closeSubpath();
 	p.strokePath(path, p.pen());
 	p.end();
+
 	Preview->setPixmap(pm);
 }

Modified: trunk/Scribus/scribus/ui/fontcombo.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24308&path=/trunk/Scribus/scribus/ui/fontcombo.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/fontcombo.cpp	(original)
+++ trunk/Scribus/scribus/ui/fontcombo.cpp	Mon Dec  7 18:30:46 2020
@@ -501,8 +501,11 @@
 
 void FontFamilyDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
 {
+	double pixelRatio = painter->device()->devicePixelRatioF();
+	int pixmapW = qRound(pixelRatio * option.rect.width());
+	int pixmapH = qRound(pixelRatio * option.rect.height());
 	QString text(index.data(Qt::DisplayRole).toString());
-	QString wh=QString("-w%1h%2").arg(option.rect.width()).arg(option.rect.height());
+	QString wh = QString("-w%1h%2").arg(pixmapW).arg(pixmapH);
 	QPixmap cachedPixmap;
 	QString cacheKey = text + wh;
 	if (option.state & QStyle::State_Selected)
@@ -516,8 +519,11 @@
 	QFontDatabase& fontDb = ScQApp->qtFontDatabase();
 	const ScFace& scFace = getScFace(this->parent()->metaObject()->className(), text);
 
-	QPixmap  pixmap(option.rect.width(), option.rect.height());
-	QPixmap  invPixmap(option.rect.width(), option.rect.height());
+	QPixmap  pixmap(pixmapW, pixmapH);
+	QPixmap  invPixmap(pixmapW, pixmapH);
+	pixmap.setDevicePixelRatio(pixelRatio);
+	invPixmap.setDevicePixelRatio(pixelRatio);
+
 	QPainter pixPainter(&pixmap);
 	QPainter invpixPainter(&invPixmap);
 

Modified: trunk/Scribus/scribus/ui/outputpreview_pdf.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24308&path=/trunk/Scribus/scribus/ui/outputpreview_pdf.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/outputpreview_pdf.cpp	(original)
+++ trunk/Scribus/scribus/ui/outputpreview_pdf.cpp	Mon Dec  7 18:30:46 2020
@@ -265,8 +265,9 @@
 QPixmap OutputPreview_PDF::createPreview(int pageIndex, int res)
 {
 	int ret = -1;
-	double w = m_doc->Pages->at(pageIndex)->width() * res / 72.0;
-	double h = m_doc->Pages->at(pageIndex)->height() * res / 72.0;
+	int gsRes = qRound(res * devicePixelRatioF());
+	int w = qRound(m_doc->Pages->at(pageIndex)->width() * gsRes / 72.0);
+	int h = qRound(m_doc->Pages->at(pageIndex)->height() * gsRes / 72.0);
 
 	qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
 
@@ -284,9 +285,9 @@
 	if (optionsHaveChanged(pageIndex))
 	{
 		if (m_optionsUi->enableCMYK->isChecked() && m_haveTiffSep)
-			ret = renderPreviewSep(pageIndex, res);
+			ret = renderPreviewSep(pageIndex, gsRes);
 		else
-			ret = renderPreview(pageIndex, res);
+			ret = renderPreview(pageIndex, gsRes);
 		if (ret > 0)
 		{
 			imageLoadError(pixmap);
@@ -302,8 +303,8 @@
 
 		ScImage im;
 		bool mode;
-		int w2 = qRound(w);
-		int h2 = qRound(h);
+		int w2 = w;
+		int h2 = h;
 		image = QImage(w2, h2, QImage::Format_ARGB32);
 		image.fill(qRgba(0, 0, 0, 0));
 		
@@ -499,9 +500,11 @@
 		}
 	}
 
+	image.setDevicePixelRatio(devicePixelRatioF());
 	if (m_optionsUi->showTransparency->isChecked())
 	{
 		pixmap = QPixmap(image.width(), image.height());
+		pixmap.setDevicePixelRatio(devicePixelRatioF());
 		QPainter p;
 		QBrush b(QColor(205,205,205), IconManager::instance().loadPixmap("testfill.png"));
 		p.begin(&pixmap);
@@ -511,6 +514,7 @@
 	}
 	else
 		pixmap = QPixmap::fromImage(image);
+	pixmap.setDevicePixelRatio(devicePixelRatioF());
 
 	qApp->restoreOverrideCursor();
 	updateOptionsFromUI();
@@ -576,13 +580,14 @@
 
 	QStringList args;
 	QString tmp, tmp2, tmp3;
-	double w = m_doc->Pages->at(pageIndex)->width() * res / 72.0;
-	double h = m_doc->Pages->at(pageIndex)->height() * res / 72.0;
+	int w = qRound(m_doc->Pages->at(pageIndex)->width() * res / 72.0);
+	int h = qRound(m_doc->Pages->at(pageIndex)->height() * res / 72.0);
+	
 	args.append( "-q" );
 	args.append( "-dNOPAUSE" );
 	args.append( "-dPARANOIDSAFER" );
 	args.append( QString("-r%1").arg(tmp.setNum(res)) );
-	args.append( QString("-g%1x%2").arg(tmp2.setNum(qRound(w)), tmp3.setNum(qRound(h))) );
+	args.append( QString("-g%1x%2").arg(tmp2.setNum(w), tmp3.setNum(h)) );
 	if (m_optionsUi->enableCMYK->isChecked())
 	{
 		if (!m_haveTiffSep)
@@ -653,14 +658,14 @@
 	QStringList args, args1, args2, args3;
 
 	QString tmp, tmp2, tmp3;
-	double w = m_doc->Pages->at(pageIndex)->width() * res / 72.0;
-	double h = m_doc->Pages->at(pageIndex)->height() * res / 72.0;
+	int w = qRound(m_doc->Pages->at(pageIndex)->width() * res / 72.0);
+	int h = qRound(m_doc->Pages->at(pageIndex)->height() * res / 72.0);
 
 	args1.append( "-q" );
 	args1.append( "-dNOPAUSE" );
 	args1.append( "-dPARANOIDSAFER" );
 	args1.append( QString("-r%1").arg(tmp.setNum(res)) );
-	args1.append( QString("-g%1x%2").arg(tmp2.setNum(qRound(w)), tmp3.setNum(qRound(h))) );
+	args1.append( QString("-g%1x%2").arg(tmp2.setNum(w), tmp3.setNum(h)) );
 	if (m_optionsUi->antiAliasing->isChecked())
 	{
 		args1.append("-dTextAlphaBits=4");
@@ -884,7 +889,7 @@
 {
 	if (m_currentPage != pageIndex)
 		return true;
-	if (m_scaleFactor != m_uiBase->scaleBox->currentIndex())
+	if (m_scaleMode != m_uiBase->scaleBox->currentIndex())
 		return true;
 	if (m_cmykPreviewMode != m_optionsUi->enableCMYK->isChecked())
 		return true;
@@ -1050,7 +1055,7 @@
 	m_convertSpots = m_optionsUi->convertSpots->isChecked();
 
 	m_currentPage = m_uiBase->pageSelector->getCurrentPage() - 1;
-	m_scaleFactor = m_uiBase->scaleBox->currentIndex();
+	m_scaleMode = m_uiBase->scaleBox->currentIndex();
 	m_cmykPreviewMode = m_optionsUi->enableCMYK->isChecked();
 	m_useAntialiasing = m_optionsUi->antiAliasing->isChecked();
 	m_showTransparency = m_optionsUi->showTransparency->isChecked();

Modified: trunk/Scribus/scribus/ui/outputpreview_ps.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24308&path=/trunk/Scribus/scribus/ui/outputpreview_ps.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/outputpreview_ps.cpp	(original)
+++ trunk/Scribus/scribus/ui/outputpreview_ps.cpp	Mon Dec  7 18:30:46 2020
@@ -293,8 +293,9 @@
 QPixmap OutputPreview_PS::createPreview(int pageIndex, int res)
 {
 	int ret = -1;
-	double w = m_doc->Pages->at(pageIndex)->width() * res / 72.0;
-	double h = m_doc->Pages->at(pageIndex)->height() * res / 72.0;
+	int gsRes = qRound(res * devicePixelRatioF());
+	int w = qRound(m_doc->Pages->at(pageIndex)->width() * gsRes / 72.0);
+	int h = qRound(m_doc->Pages->at(pageIndex)->height() * gsRes / 72.0);
 
 	qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
 
@@ -312,9 +313,9 @@
 	if (optionsHaveChanged(pageIndex))
 	{
 		if (m_optionsUi->enableCMYK->isChecked() && m_haveTiffSep)
-			ret = renderPreviewSep(pageIndex, res);
+			ret = renderPreviewSep(pageIndex, gsRes);
 		else
-			ret = renderPreview(pageIndex, res);
+			ret = renderPreview(pageIndex, gsRes);
 		if (ret > 0)
 		{
 			imageLoadError(pixmap);
@@ -330,8 +331,8 @@
 
 		ScImage im;
 		bool mode;
-		int w2 = qRound(w);
-		int h2 = qRound(h);
+		int w2 = w;
+		int h2 = h;
 		if (m_doc->Pages->at(pageIndex)->orientation() == 1)
 			std::swap(w2, h2);
 		image = QImage(w2, h2, QImage::Format_ARGB32);
@@ -532,9 +533,12 @@
 	const ScPage* page = m_doc->Pages->at(pageIndex);
 	if ((page->orientation() == 1) && (image.width() < image.height()))
 		image = image.transformed( QTransform(0, 1, -1, 0, 0, 0) );
+
+	image.setDevicePixelRatio(devicePixelRatioF());
 	if (m_optionsUi->showTransparency->isChecked())
 	{
 		pixmap = QPixmap(image.width(), image.height());
+		pixmap.setDevicePixelRatio(devicePixelRatioF());
 		QPainter p;
 		QBrush b(QColor(205,205,205), IconManager::instance().loadPixmap("testfill.png"));
 		p.begin(&pixmap);
@@ -544,6 +548,7 @@
 	}
 	else
 		pixmap = QPixmap::fromImage(image);
+	pixmap.setDevicePixelRatio(devicePixelRatioF());
 
 	qApp->restoreOverrideCursor();
 	updateOptionsFromUI();
@@ -610,8 +615,8 @@
 
 	QStringList args;
 	QString tmp, tmp2, tmp3;
-	double w = m_doc->Pages->at(pageIndex)->width() * res / 72.0;
-	double h = m_doc->Pages->at(pageIndex)->height() * res / 72.0;
+	int w = qRound(m_doc->Pages->at(pageIndex)->width() * res / 72.0);
+	int h = qRound(m_doc->Pages->at(pageIndex)->height() * res / 72.0);
 	if (m_doc->Pages->at(pageIndex)->orientation() == 1)
 		std::swap(w, h);
 
@@ -619,7 +624,7 @@
 	args.append( "-dNOPAUSE" );
 	args.append( "-dPARANOIDSAFER" );
 	args.append( QString("-r%1").arg(tmp.setNum(res)) );
-	args.append( QString("-g%1x%2").arg(tmp2.setNum(qRound(w)), tmp3.setNum(qRound(h))) );
+	args.append( QString("-g%1x%2").arg(tmp2.setNum(w), tmp3.setNum(h)) );
 	if (m_optionsUi->enableCMYK->isChecked())
 	{
 		if (!m_haveTiffSep)
@@ -690,8 +695,8 @@
 	QStringList args, args1, args2, args3;
 
 	QString tmp, tmp2, tmp3;
-	double w = m_doc->Pages->at(pageIndex)->width() * res / 72.0;
-	double h = m_doc->Pages->at(pageIndex)->height() * res / 72.0;
+	int w = qRound(m_doc->Pages->at(pageIndex)->width() * res / 72.0);
+	int h = qRound(m_doc->Pages->at(pageIndex)->height() * res / 72.0);
 	if (m_doc->Pages->at(pageIndex)->orientation() == 1)
 		std::swap(w, h);
 
@@ -699,7 +704,7 @@
 	args1.append( "-dNOPAUSE" );
 	args1.append( "-dPARANOIDSAFER" );
 	args1.append( QString("-r%1").arg(tmp.setNum(res)) );
-	args1.append( QString("-g%1x%2").arg(tmp2.setNum(qRound(w)), tmp3.setNum(qRound(h))) );
+	args1.append( QString("-g%1x%2").arg(tmp2.setNum(w), tmp3.setNum(h)) );
 	if (m_optionsUi->antiAliasing->isChecked())
 	{
 		args1.append("-dTextAlphaBits=4");
@@ -822,7 +827,7 @@
 {
 	if (m_currentPage != pageIndex)
 		return true;
-	if (m_scaleFactor != m_uiBase->scaleBox->currentIndex())
+	if (m_scaleMode != m_uiBase->scaleBox->currentIndex())
 		return true;
 	if (m_cmykPreviewMode != m_optionsUi->enableCMYK->isChecked())
 		return true;
@@ -931,7 +936,7 @@
 	m_enableGCR = m_optionsUi->enableGCR->isChecked();
 
 	m_currentPage = m_uiBase->pageSelector->getCurrentPage() - 1;
-	m_scaleFactor = m_uiBase->scaleBox->currentIndex();
+	m_scaleMode = m_uiBase->scaleBox->currentIndex();
 	m_cmykPreviewMode = m_optionsUi->enableCMYK->isChecked();
 	m_useAntialiasing = m_optionsUi->antiAliasing->isChecked();
 	m_showTransparency = m_optionsUi->showTransparency->isChecked();

Modified: trunk/Scribus/scribus/ui/polygonwidget.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24308&path=/trunk/Scribus/scribus/ui/polygonwidget.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/polygonwidget.cpp	(original)
+++ trunk/Scribus/scribus/ui/polygonwidget.cpp	Mon Dec  7 18:30:46 2020
@@ -209,13 +209,22 @@
 	}
 	double roundness = curvatureSpinBox->value() / 100.0;
 	double innerround = outerCurvatureSpinBox->value() / 100.0;
-	QPixmap pm = QPixmap(Preview->width() - 5, Preview->height() - 5);
+
+	int polyWidth = Preview->width() - 6;
+	int polyHeight = Preview->height() - 6;
+	int pixWidth = (Preview->width() - 5) * devicePixelRatioF();
+	int pixHeight = (Preview->height() - 5) * devicePixelRatioF();
+
+	QPixmap pm(pixWidth, pixHeight);
+	pm.setDevicePixelRatio(devicePixelRatioF());
 	pm.fill(Qt::white);
+
 	QPainter p;
 	p.begin(&pm);
+	p.setRenderHint(QPainter::Antialiasing, true);
 	p.setBrush(Qt::NoBrush);
 	p.setPen(Qt::black);
-	QPainterPath pp = regularPolygonPath(Preview->width() - 6, Preview->height() - 6, cornersSpinBox->value(), applyConvexGroupBox->isChecked(), GetFactor(), rotationSlider->value(), roundness, innerRotationSpinBox->value(), innerround);
+	QPainterPath pp = regularPolygonPath(polyWidth, polyHeight, cornersSpinBox->value(), applyConvexGroupBox->isChecked(), GetFactor(), rotationSlider->value(), roundness, innerRotationSpinBox->value(), innerround);
 	QRectF br = pp.boundingRect();
 	if (br.x() < 0)
 	{
@@ -230,15 +239,16 @@
 		pp = pp * m;
 	}
 	br = pp.boundingRect();
-	if ((br.height() > Preview->height() - 6) || (br.width() > Preview->width() - 6))
+	if ((br.height() > polyHeight) || (br.width() > polyWidth))
 	{
 		QTransform ma;
-		double sca = static_cast<double>(qMax(Preview->height() - 6, Preview->width() - 6)) / static_cast<double>(qMax(br.width(), br.height()));
+		double sca = static_cast<double>(qMax(polyHeight, polyWidth)) / static_cast<double>(qMax(br.width(), br.height()));
 		ma.scale(sca, sca);
 		pp = pp * ma;
 	}
 	p.strokePath(pp, p.pen());
 	p.end();
+
 	Preview->setPixmap(pm);
 }
 

Modified: trunk/Scribus/scribus/ui/prefs_itemtools.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24308&path=/trunk/Scribus/scribus/ui/prefs_itemtools.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/prefs_itemtools.cpp	(original)
+++ trunk/Scribus/scribus/ui/prefs_itemtools.cpp	Mon Dec  7 18:30:46 2020
@@ -379,6 +379,7 @@
 		return;
 
 	SampleItem si;
+	si.setDevicePixelRatio(devicePixelRatioF());
 	si.setText( tr("Woven silk pyjamas exchanged for blue quartz"));
 	if (textFrameFillColorComboBox->currentText() != CommonStrings::tr_NoneColor)
 	{
@@ -388,8 +389,8 @@
 		}
 		else
 		{
-			PrefsManager& prefsManager=PrefsManager::instance();
-			ColorList* colorList=prefsManager.colorSetPtr();
+			PrefsManager& prefsManager = PrefsManager::instance();
+			ColorList* colorList = prefsManager.colorSetPtr();
 			si.setBgColor((*colorList)[textFrameFillColorComboBox->currentText()].getRawRGBColor());
 		}
 		si.setBgShade(textFrameFillShadingSpinBox->value());
@@ -405,8 +406,8 @@
 		}
 		else
 		{
-			PrefsManager& prefsManager=PrefsManager::instance();
-			ColorList* colorList=prefsManager.colorSetPtr();
+			PrefsManager& prefsManager = PrefsManager::instance();
+			ColorList* colorList = prefsManager.colorSetPtr();
 			si.setTxColor((*colorList)[textColorComboBox->currentText()].getRawRGBColor());
 		}
 		si.setTxShade(textColorShadingSpinBox->value());

Modified: trunk/Scribus/scribus/ui/printpreview.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24308&path=/trunk/Scribus/scribus/ui/printpreview.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/printpreview.cpp	(original)
+++ trunk/Scribus/scribus/ui/printpreview.cpp	Mon Dec  7 18:30:46 2020
@@ -97,6 +97,7 @@
 	m_ui->printLanguageCombo->setCurrentLanguage(engine);
 
 	m_previewCreator = PrintPreviewCreatorFactory::create(docu, m_ui->printLanguageCombo->currentLanguage());
+	m_previewCreator->setDevicePixelRatio(devicePixelRatioF());
 
 	m_useGhostscript = m_previewCreator->isGhostscriptBased();
 	m_haveTiffSep  = ScCore->haveTIFFSep() && (m_ui->printLanguageCombo->hasPDF() || m_ui->printLanguageCombo->hasPostscript());
@@ -430,6 +431,8 @@
 	PrintLanguage newPrnLanguage = m_ui->printLanguageCombo->currentLanguage();
 	m_previewCreator = PrintPreviewCreatorFactory::create(m_doc, newPrnLanguage);
 	m_useGhostscript = m_previewCreator->isGhostscriptBased();
+
+	m_previewCreator->setDevicePixelRatio(devicePixelRatioF());
 
 	m_ui->antiAliasing->setEnabled(m_useGhostscript);
 	m_ui->showTransparency->setEnabled(m_useGhostscript);
@@ -534,6 +537,7 @@
 		m_previewCreator->setPrintOptions(options);
 	}
 
+	m_previewCreator->setDevicePixelRatio(devicePixelRatioF());
 	m_previewCreator->setPreviewResolution(res);
 	m_previewCreator->setAntialisingEnabled(m_ui->antiAliasing->isChecked());
 	m_previewCreator->setShowTransparency(m_ui->showTransparency->isChecked());

Modified: trunk/Scribus/scribus/ui/spiralwidget.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24308&path=/trunk/Scribus/scribus/ui/spiralwidget.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/spiralwidget.cpp	(original)
+++ trunk/Scribus/scribus/ui/spiralwidget.cpp	Mon Dec  7 18:30:46 2020
@@ -67,15 +67,25 @@
 {
 	startAngle->setMaximum(endAngle->value() - 1);
 	endAngle->setMinimum(startAngle->value() + 1);
-	QPixmap pm = QPixmap(Preview->width() - 5, Preview->height() - 5);
+	
+	int spiralWidth = Preview->width() - 11;
+	int spiralHeight = Preview->height() - 11;
+	int pixWidth = (Preview->width() - 5) * devicePixelRatioF();
+	int pixHeight = (Preview->height() - 5) * devicePixelRatioF();
+
+	QPixmap pm(pixWidth, pixHeight);
+	pm.setDevicePixelRatio(devicePixelRatioF());
 	pm.fill(Qt::white);
+
 	QPainter p;
 	p.begin(&pm);
+	p.setRenderHint(QPainter::Antialiasing, true);
 	p.setBrush(Qt::NoBrush);
 	p.setPen(Qt::black);
-	QPainterPath path = spiralPath(pm.width() - 6, pm.height() - 6, startAngle->value(), endAngle->value(), (static_cast<int>(arcFactor->value()) + 100) / 100.0);
+	QPainterPath path = spiralPath(spiralWidth, spiralHeight, startAngle->value(), endAngle->value(), (static_cast<int>(arcFactor->value()) + 100) / 100.0);
 	path.translate(3, 3);
 	p.strokePath(path, p.pen());
 	p.end();
+
 	Preview->setPixmap(pm);
 }




More information about the scribus-commit mailing list