r22780 by jghali - #15498: 79 page document crashes Scribus upon export to PDF

scribus-commit scribus-commit at lists.scribus.net
Thu Dec 6 22:08:24 UTC 2018


Author: jghali
Date: Thu Dec  6 22:08:24 2018
New Revision: 22780

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=22780
Log:
#15498: 79 page document crashes Scribus upon export to PDF

Modified:
    trunk/Scribus/scribus/pdflib_core.cpp
    trunk/Scribus/scribus/plugins/export/svgexplugin/svgexplugin.cpp
    trunk/Scribus/scribus/plugins/export/xpsexport/xpsexplugin.cpp
    trunk/Scribus/scribus/pslib.cpp
    trunk/Scribus/scribus/scribusdoc.cpp

Modified: trunk/Scribus/scribus/pdflib_core.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22780&path=/trunk/Scribus/scribus/pdflib_core.cpp
==============================================================================
--- trunk/Scribus/scribus/pdflib_core.cpp	(original)
+++ trunk/Scribus/scribus/pdflib_core.cpp	Thu Dec  6 22:08:24 2018
@@ -150,6 +150,12 @@
 		double current_x = 0.0;
 		for (const GlyphLayout& gl : gc.glyphs())
 		{
+			if (gl.glyph >= ScFace::CONTROL_GLYPHS)
+			{
+				current_x += gl.xadvance;
+				continue;
+			}
+
 			PdfFont pdfFont = m_pdf->UsedFontsP[font().replacementName()];
 			QByteArray StrokeColor;
 			QByteArray FillColor;
@@ -253,6 +259,12 @@
 		double current_x = 0.0;
 		for (const GlyphLayout& gl : gc.glyphs())
 		{
+			if (gl.glyph >= ScFace::CONTROL_GLYPHS)
+			{
+				current_x += gl.xadvance;
+				continue;
+			}
+
 			PdfFont pdfFont = m_pdf->UsedFontsP[font().replacementName()];
 			QByteArray StrokeColor;
 			QByteArray FillColor;

Modified: trunk/Scribus/scribus/plugins/export/svgexplugin/svgexplugin.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22780&path=/trunk/Scribus/scribus/plugins/export/svgexplugin/svgexplugin.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/export/svgexplugin/svgexplugin.cpp	(original)
+++ trunk/Scribus/scribus/plugins/export/svgexplugin/svgexplugin.cpp	Thu Dec  6 22:08:24 2018
@@ -1156,11 +1156,17 @@
 
 	void drawGlyph(const GlyphCluster& gc)
 	{
-		if (gc.isControlGlyphs())
+		if (gc.isControlGlyphs() || gc.isEmpty())
 			return;
 		double current_x = 0.0;
 		for (const GlyphLayout& gl : gc.glyphs())
 		{
+			if (gl.glyph >= ScFace::CONTROL_GLYPHS)
+			{
+				current_x += gl.xadvance;
+				continue;
+			}
+
 			QTransform transform = matrix();
 			transform.translate(x() + gl.xoffset + current_x, y() - (fontSize() * gc.scaleV()) + gl.yoffset);
 			transform.scale(gc.scaleH() * fontSize() / 10.0, gc.scaleV() * fontSize() / 10.0);
@@ -1171,17 +1177,25 @@
 			QString stroke = "stroke:none;";
 			glyph.setAttribute("style", fill + stroke);
 			m_elem.appendChild(glyph);
+
 			current_x += gl.xadvance;
 		}
-
-	}
+	}
+
 	void drawGlyphOutline(const GlyphCluster& gc, bool hasFill)
 	{
-		if (gc.isControlGlyphs())
+		if (gc.isControlGlyphs() | gc.isEmpty())
 			return;
+
 		double current_x = 0.0;
 		for (const GlyphLayout& gl : gc.glyphs())
 		{
+			if (gl.glyph >= ScFace::CONTROL_GLYPHS)
+			{
+				current_x += gl.xadvance;
+				continue;
+			}
+
 			QTransform transform = matrix();
 			transform.translate(x() + gl.xoffset + current_x, y() - (fontSize() * gc.scaleV()) + gl.yoffset);
 			transform.scale(gc.scaleH() * fontSize() / 10.0, gc.scaleV() * fontSize() / 10.0);
@@ -1195,10 +1209,11 @@
 			stroke += " stroke-width:" + m_svg->FToStr(strokeWidth() / (gc.scaleV() * fontSize() / 10.0)) + ";";
 			glyph.setAttribute("style", fill + stroke);
 			m_elem.appendChild(glyph);
+
 			current_x += gl.xadvance;
 		}
-
-	}
+	}
+
 	void drawLine(QPointF start, QPointF end)
 	{
 		QTransform transform = matrix();

Modified: trunk/Scribus/scribus/plugins/export/xpsexport/xpsexplugin.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22780&path=/trunk/Scribus/scribus/plugins/export/xpsexport/xpsexplugin.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/export/xpsexport/xpsexplugin.cpp	(original)
+++ trunk/Scribus/scribus/plugins/export/xpsexport/xpsexplugin.cpp	Thu Dec  6 22:08:24 2018
@@ -814,7 +814,7 @@
 
 	void drawGlyph(const GlyphCluster& gc)
 	{
-		if (gc.isControlGlyphs())
+		if (gc.isControlGlyphs() || gc.isEmpty())
 			return;
 
 		if (!m_fontMap.contains(font().replacementName()))
@@ -834,7 +834,14 @@
 		QString gcMap = QString("(%1:%2)").arg(gc.getText().size()).arg(gc.glyphs().size());
 		QString indices;
 		double current_x = 0.0;
-		for (const GlyphLayout& gl : gc.glyphs()) {
+		for (const GlyphLayout& gl : gc.glyphs()) 
+		{
+			if (gl.glyph >= ScFace::CONTROL_GLYPHS)
+			{
+				current_x += gl.xadvance;
+				continue;
+			}
+
 			indices += QString("%1,%2,%3,%4;").arg(gl.glyph)
 					.arg(((gl.xadvance + current_x) * m_xps->conversionFactor) / size * 100)
 					.arg((-gl.xoffset * m_xps->conversionFactor) / size * 100)
@@ -850,8 +857,16 @@
 	{
 		if (gc.isControlGlyphs())
 			return;
+
 		double current_x = 0.0;
-		for (const GlyphLayout& gl : gc.glyphs()) {
+		for (const GlyphLayout& gl : gc.glyphs())
+		{
+			if (gl.glyph >= ScFace::CONTROL_GLYPHS)
+			{
+				current_x += gl.xadvance;
+				continue;
+			}
+
 			FPointArray outline = font().glyphOutline(gl.glyph);
 			if (outline.size() >= 4)
 			{

Modified: trunk/Scribus/scribus/pslib.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22780&path=/trunk/Scribus/scribus/pslib.cpp
==============================================================================
--- trunk/Scribus/scribus/pslib.cpp	(original)
+++ trunk/Scribus/scribus/pslib.cpp	Thu Dec  6 22:08:24 2018
@@ -105,12 +105,20 @@
 {
 	if (gc.isControlGlyphs() || gc.isEmpty())
 		return;
+
 	m_ps->PS_save();
 	applyTransform();
 	m_ps->PS_translate(x(), -(y() - fontSize()));
+
 	double current_x = 0.0;
 	for (const GlyphLayout& gl : gc.glyphs())
 	{
+		if (gl.glyph >= ScFace::CONTROL_GLYPHS)
+		{
+			current_x += gl.xadvance;
+			continue;
+		}
+
 		m_ps->PS_save();
 		m_ps->PS_translate(gl.xoffset + current_x, -(fontSize() - fontSize() * gl.scaleV) - gl.yoffset);
 		if (gl.scaleH != 1.0 || (gl.scaleV != 1.0))
@@ -120,6 +128,7 @@
 			m_ps->putColorNoDraw(fillColor().color, fillColor().shade);
 		m_ps->PS_showSub(gl.glyph, m_ps->FontSubsetMap[font().scName()], fontSize(), false);
 		m_ps->PS_restore();
+
 		current_x += gl.xadvance;
 	}
 	m_ps->PS_restore();
@@ -129,41 +138,49 @@
 {
 	if (gc.isControlGlyphs() || gc.isEmpty())
 		return;
+	if (strokeColor().color == CommonStrings::None)
+		return;
 
 	double h, s, v, k;
 	QVector<double> dum;
-	dum.clear();
+
 	m_ps->PS_save();
 	applyTransform();
-	if (strokeColor().color != CommonStrings::None)
-	{
-		m_ps->PS_setlinewidth(strokeWidth());
-		m_ps->PS_setcapjoin(Qt::FlatCap, Qt::MiterJoin);
-		m_ps->PS_setdash(Qt::SolidLine, 0, dum);
-		m_ps->PS_translate(x(), -(y() - fontSize()));
-		double current_x = 0.0;
-		for (const GlyphLayout& gl : gc.glyphs())
-		{
-			m_ps->PS_save();
-			FPointArray gly = font().glyphOutline(gl.glyph);
-			QTransform chma;
-			chma.scale((fontSize() * gc.scaleH()) / 10.0, (fontSize() * gc.scaleV()) / 10.0);
-			gly.map(chma);
-			m_ps->PS_translate(gl.xoffset + current_x, -(fontSize() - fontSize() * gc.scaleV()) - gl.yoffset);
-			if (gc.scaleH() != 1.0 || gc.scaleV() != 1.0)
-				m_ps->PS_scale(gc.scaleH(), gc.scaleV());
-			if (fill)
-				m_ps->putColorNoDraw(fillColor().color, fillColor().shade);
-			m_ps->PS_showSub(gl.glyph, m_ps->FontSubsetMap[font().scName()], fontSize(), false);
-			m_ps->SetColor(strokeColor().color, strokeColor().shade, &h, &s, &v, &k);
-			m_ps->PS_setcmykcolor_stroke(h, s, v, k);
-			m_ps->SetClipPath(gly, true);
-			m_ps->PS_closepath();
-			m_ps->putColor(strokeColor().color, strokeColor().shade, false);
-			m_ps->PS_restore();
+	m_ps->PS_setlinewidth(strokeWidth());
+	m_ps->PS_setcapjoin(Qt::FlatCap, Qt::MiterJoin);
+	m_ps->PS_setdash(Qt::SolidLine, 0, dum);
+	m_ps->PS_translate(x(), -(y() - fontSize()));
+
+	double current_x = 0.0;
+	for (const GlyphLayout& gl : gc.glyphs())
+	{
+		if (gl.glyph >= ScFace::CONTROL_GLYPHS)
+		{
 			current_x += gl.xadvance;
-		}
-	}
+			continue;
+		}
+
+		m_ps->PS_save();
+		FPointArray gly = font().glyphOutline(gl.glyph);
+		QTransform chma;
+		chma.scale((fontSize() * gc.scaleH()) / 10.0, (fontSize() * gc.scaleV()) / 10.0);
+		gly.map(chma);
+		m_ps->PS_translate(gl.xoffset + current_x, -(fontSize() - fontSize() * gc.scaleV()) - gl.yoffset);
+		if (gc.scaleH() != 1.0 || gc.scaleV() != 1.0)
+			m_ps->PS_scale(gc.scaleH(), gc.scaleV());
+		if (fill)
+			m_ps->putColorNoDraw(fillColor().color, fillColor().shade);
+		m_ps->PS_showSub(gl.glyph, m_ps->FontSubsetMap[font().scName()], fontSize(), false);
+		m_ps->SetColor(strokeColor().color, strokeColor().shade, &h, &s, &v, &k);
+		m_ps->PS_setcmykcolor_stroke(h, s, v, k);
+		m_ps->SetClipPath(gly, true);
+		m_ps->PS_closepath();
+		m_ps->putColor(strokeColor().color, strokeColor().shade, false);
+		m_ps->PS_restore();
+
+		current_x += gl.xadvance;
+	}
+
 	m_ps->PS_restore();
 }
 

Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22780&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp	(original)
+++ trunk/Scribus/scribus/scribusdoc.cpp	Thu Dec  6 22:08:24 2018
@@ -4411,11 +4411,15 @@
 			return;
 		for (const GlyphLayout& gl : gc.glyphs())
 		{
+			uint gid = gl.glyph;
+			if (gid >= ScFace::CONTROL_GLYPHS)
+				continue;
+
 			QString replacementName = font().replacementName();
 			if (!replacementName.isEmpty())
 			{
-				FPointArray outline = font().glyphOutline(gl.glyph);
-				m_really[replacementName].insert(gl.glyph, outline);
+				FPointArray outline = font().glyphOutline(gid);
+				m_really[replacementName].insert(gid, outline);
 			}
 		}
 	}




More information about the scribus-commit mailing list