r14323 by jghali - #8592, incorrect postscript separations : fix quite some issues, now our separations looks more like Ghostscript ones

scribus-commit scribus-commit at lists.scribus.net
Sat Nov 21 20:20:25 CET 2009


Revision: 14323
Author: jghali
Date: 2009-11-21T10:26:09.939454Z
Commit message: #8592, incorrect postscript separations : fix quite some issues, now our separations looks more like Ghostscript ones

Changeset: 
M  /branches/Version135/Scribus/scribus/pslib.cpp
M  /branches/Version135/Scribus/scribus/pslib.h

Diffs:
Index: scribus/pslib.h
===================================================================
--- scribus/pslib.h	(revision 14322)
+++ scribus/pslib.h	(revision 14323)
@@ -110,7 +110,7 @@
 		virtual void PS_MultiLinGradient(double w, double h, QList<double> Stops, QStringList Colors, QStringList colorNames, QList<int> colorShades);
 		virtual void PS_show(double x, double y);
 		virtual void PS_showSub(uint chr, QString font, double size, bool stroke);
-		virtual void PS_show_xyG(QString font, uint gl, double x, double y, bool stop);
+		virtual void PS_show_xyG(QString font, uint gl, double x, double y, QString colorName, double shade);
 		virtual bool PS_image(PageItem *c, double x, double y, QString fn, double scalex, double scaley, QString Prof, bool UseEmbedded, bool UseProf, QString Name = "");
 		virtual bool PS_ImageData(PageItem *c, QString fn, QString Name, QString Prof, bool UseEmbedded, bool UseProf);
 		virtual void PS_plate(int nr, QString name = "");
@@ -126,6 +126,7 @@
 		virtual void ProcessPage(ScribusDoc* Doc, /*ScribusView* view,*/Page* a, uint PNr, bool sep = false, bool farb = true, bool ic = false, bool gcr = true);
 		virtual void drawArrow(PageItem *ite, QMatrix &arrowTrans, int arrowIndex, bool gcr);
 		virtual void putColor(const QString& color, double shade, bool fill);
+		virtual void putColorNoDraw(const QString& color, double shade, bool gcr);
 		virtual void GetBleeds(Page* page, double& left, double& right);
 		virtual void GetBleeds(Page* page, double& left, double& right, double& bottom, double& top);
 		virtual void SetClipPath(FPointArray *c, bool poly = true);
Index: scribus/pslib.cpp
===================================================================
--- scribus/pslib.cpp	(revision 14322)
+++ scribus/pslib.cpp	(revision 14323)
@@ -1360,14 +1360,42 @@
 	PutStream("cliprestore\n");
 }
 
-void PSLib::PS_show_xyG(QString font, uint glyph, double x, double y, bool spot)
+void PSLib::PS_show_xyG(QString font, uint glyph, double x, double y, QString colorName, double shade)
 {
-	QString Name;
-	Name = GlyphsOfFont[font].contains(glyph) ? GlyphsOfFont[font][glyph].second : QString(".notdef");
+	QString glyphName;
+	glyphName = GlyphsOfFont[font].contains(glyph) ? GlyphsOfFont[font][glyph].second : QString(".notdef");
+
+	QString colorString;
+	ScColor& color(colorsToUse[colorName]);
+	bool spot = false;
+	if (((color.isSpotColor()) || (color.isRegistrationColor())) && (useSpotColors))
+	{
+		if (!DoSep)
+		{
+			colorString = ToStr(shade / 100.0)+" "+spotMap[colorName];
+			spot = true;
+		}
+		else if ((colorName == currentSpot) || (color.isRegistrationColor()))
+			colorString = "0 0 0 "+ToStr(shade / 100.0);
+		else
+			colorString = "0 0 0 0";
+	}
+	else
+	{
+		int c, m, y, k;
+		SetColor(color, shade, &c, &m, &y, &k, Options.doGCR);
+		if (!DoSep || (Plate == 0 || Plate == 1 || Plate == 2 || Plate == 3))
+			colorString = ToStr(c / 255.0) + " " + ToStr(m / 255.0) + " " + ToStr(y / 255.0) + " " + ToStr(k / 255.0);
+		else
+			colorString = "0 0 0 0";
+	}
 	if (spot)
-		PutStream("/"+Name+" "+ToStr(x)+" "+ToStr(y)+" shgsp\n");
+	{
+		PutStream(colorString + "\n");
+		PutStream("/"+glyphName+" "+ToStr(x)+" "+ToStr(y)+" shgsp\n");
+	}
 	else
-		PutStream("/"+Name+" "+ToStr(x)+" "+ToStr(y)+" "+StrokeColor+" shg\n");
+		PutStream("/"+glyphName+" "+ToStr(x)+" "+ToStr(y)+" "+colorString+" shg\n");
 }
 
 void PSLib::PS_show(double x, double y)
@@ -2828,21 +2856,11 @@
 								{
 									PS_save();
 									PS_translate(style.fontSize() * style.shadowXOffset() / 10000.0, style.fontSize() * style.shadowYOffset() / 10000.0);
-									SetColor(style.strokeColor(), style.strokeShade(), &h, &s, &v, &k, gcr);
-									PS_setcmykcolor_fill(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
-									if ((colorsToUse[style.strokeColor()].isSpotColor()) && (!DoSep))
-										PutStream(ToStr(style.strokeShade() / 100.0)+" "+spotMap[style.strokeColor()]);
-									else
-										PutStream(FillColor + " cmyk");
+									putColorNoDraw(style.strokeColor(), style.strokeShade(), gcr);
 									PS_showSub(chr, FontSubsetMap[style.font().scName()], tsz / 10.0, false);
 									PS_restore();
 								}
-								SetColor(style.fillColor(), style.fillShade(), &h, &s, &v, &k, gcr);
-								PS_setcmykcolor_fill(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
-								if ((colorsToUse[style.fillColor()].isSpotColor()) && (!DoSep))
-									PutStream(ToStr(style.fillShade() / 100.0)+" "+spotMap[style.fillColor()]);
-								else
-									PutStream(FillColor + " cmyk");
+								putColorNoDraw(style.fillColor(), style.fillShade(), gcr);
 								PS_showSub(chr, FontSubsetMap[style.font().scName()], tsz / 10.0, false);
 								if ((style.effects() & ScStyle_Outline))
 								{
@@ -2850,12 +2868,7 @@
 									{
 										PS_save();
 										PS_setlinewidth(tsz * style.outlineWidth() / 10000.0);
-										SetColor(style.strokeColor(), style.strokeShade(), &h, &s, &v, &k, gcr);
-										PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
-										if ((colorsToUse[style.strokeColor()].isSpotColor()) && (!DoSep))
-											PutStream(ToStr(style.strokeShade() / 100.0)+" "+spotMap[style.strokeColor()]);
-										else
-											PutStream(StrokeColor + " cmyk");
+										putColorNoDraw(style.strokeColor(), style.strokeShade(), gcr);
 										PS_showSub(chr, FontSubsetMap[style.font().scName()], tsz / 10.0, true);
 										PS_restore();
 									}
@@ -2991,26 +3004,10 @@
 						{
 							PS_save();
 							PS_translate(style.fontSize() * style.shadowXOffset() / 10000.0, style.fontSize() * style.shadowYOffset() / 10000.0);
-							SetColor(style.strokeColor(), style.strokeShade(), &h, &s, &v, &k, gcr);
-							PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
-							if ((colorsToUse[style.strokeColor()].isSpotColor()) && (!DoSep))
-							{
-								PutStream(ToStr(style.strokeShade() / 100.0)+" "+spotMap[style.strokeColor()]);
-								PS_show_xyG(style.font().replacementName(), glyph, 0, 0, true);
-							}
-							else
-								PS_show_xyG(style.font().replacementName(), glyph, 0, 0, false);
+							PS_show_xyG(style.font().replacementName(), glyph, 0, 0, style.strokeColor(), style.strokeShade());
 							PS_restore();
 						}
-						SetColor(style.fillColor(), style.fillShade(), &h, &s, &v, &k, gcr);
-						PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
-						if ((colorsToUse[style.fillColor()].isSpotColor()) && (!DoSep))
-						{
-							PutStream(ToStr(style.fillShade() / 100.0)+" "+spotMap[style.fillColor()]);
-							PS_show_xyG(style.font().replacementName(), glyph, 0, 0, true);
-						}
-						else
-							PS_show_xyG(style.font().replacementName(), glyph, 0, 0, false);
+						PS_show_xyG(style.font().replacementName(), glyph, 0, 0, style.fillColor(), style.fillShade());
 						if ((style.effects() & ScStyle_Outline))
 						{
 							if ((style.strokeColor() != CommonStrings::None) && ((tsz * style.outlineWidth() / 10000.0) != 0))
@@ -3831,12 +3828,7 @@
 				}
 				if (cstyle.fillColor() != CommonStrings::None)
 				{
-					SetColor(cstyle.fillColor(), cstyle.fillShade(), &h, &s, &v, &k, gcr);
-					PS_setcmykcolor_fill(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
-					if ((colorsToUse[cstyle.fillColor()].isSpotColor()) && (!DoSep) && (useSpotColors))
-						PutStream(ToStr(cstyle.fillShade() / 100.0)+" "+spotMap[cstyle.fillColor()]);
-					else
-						PutStream(FillColor + " cmyk");
+					putColorNoDraw(cstyle.fillColor(), cstyle.fillShade(), gcr);
 					PS_showSub(glyph, FontSubsetMap[cstyle.font().scName()], tsz / 10.0, false);
 				}
 				PS_restore();
@@ -3858,15 +3850,7 @@
 				PS_scale(glyphs.scaleH, glyphs.scaleV);
 			if (cstyle.fillColor() != CommonStrings::None)
 			{
-				SetColor(cstyle.fillColor(), cstyle.fillShade(), &h, &s, &v, &k, gcr);
-				PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
-				if ((colorsToUse[cstyle.fillColor()].isSpotColor()) && (!DoSep) && (useSpotColors))
-				{
-					PutStream(ToStr(cstyle.fillShade() / 100.0)+" "+spotMap[cstyle.fillColor()]);
-					PS_show_xyG(cstyle.font().replacementName(), glyph, 0, 0, true);
-				}
-				else
-					PS_show_xyG(cstyle.font().replacementName(), glyph, 0, 0, false);
+				PS_show_xyG(cstyle.font().replacementName(), glyph, 0, 0, cstyle.fillColor(), cstyle.fillShade());
 			}
 			PS_restore();
 		}
@@ -3983,61 +3967,88 @@
 	}*/
 }
 
-void PSLib::putColor(const QString& color, double shade, bool fill)
+void PSLib::putColor(const QString& colorName, double shade, bool fill)
 {
+	ScColor& color(colorsToUse[colorName]);
 	if (fill)
 	{
-		if (((colorsToUse[color].isSpotColor()) || (colorsToUse[color].isRegistrationColor())) && (useSpotColors))
+		if (((color.isSpotColor()) || (color.isRegistrationColor())) && (useSpotColors))
 		{
 			if (!DoSep)
-				PS_fillspot(color, shade);
+				PS_fillspot(colorName, shade);
 			else
 			{
-				if ((color == currentSpot) || (colorsToUse[color].isRegistrationColor()))
+				if ((colorName == currentSpot) || (color.isRegistrationColor()))
 				{
 					if (fillRule)
 						PutStream("0 0 0 "+ToStr(shade / 100.0)+" cmyk eofill\n");
 					else
 						PutStream("0 0 0 "+ToStr(shade / 100.0)+" cmyk fill\n");
 				}
+				else
+				{
+					if (fillRule)
+						PutStream("0 0 0 0 cmyk eofill\n");
+					else
+						PutStream("0 0 0 0 cmyk fill\n");
+				}
 			}
 		}
 		else
 		{
-			if (DoSep)
-			{
-				if ((Plate == 0) || (Plate == 1) || (Plate == 2) || (Plate == 3))
-					PS_fill();
-			}
+			if (!DoSep || (Plate == 0) || (Plate == 1) || (Plate == 2) || (Plate == 3))
+				PS_fill();
+			else if (fillRule)
+				PutStream("0 0 0 0 cmyk eofill\n");
 			else
-				PS_fill();
+				PutStream("0 0 0 0 cmyk fill\n");
 		}
 	}
 	else
 	{
-		if (((colorsToUse[color].isSpotColor()) || (colorsToUse[color].isRegistrationColor())) && (useSpotColors))
+		if (((color.isSpotColor()) || (color.isRegistrationColor())) && (useSpotColors))
 		{
 			if (!DoSep)
-				PS_strokespot(color, shade);
+				PS_strokespot(colorName, shade);
 			else
 			{
-				if ((color == currentSpot) || (colorsToUse[color].isRegistrationColor()))
+				if ((colorName == currentSpot) || (color.isRegistrationColor()))
 					PutStream("0 0 0 "+ToStr(shade / 100.0)+" cmyk st\n");
 			}
 		}
 		else
 		{
-			if (DoSep)
-			{
-				if ((Plate == 0) || (Plate == 1) || (Plate == 2) || (Plate == 3))
-					PS_stroke();
-			}
+			if (!DoSep || (Plate == 0) || (Plate == 1) || (Plate == 2) || (Plate == 3))
+				PS_stroke();
 			else
-				PS_stroke();
+				PutStream("0 0 0 0 cmyk st\n");
 		}
 	}
 }
 
+void PSLib::putColorNoDraw(const QString& colorName, double shade, bool gcr)
+{
+	ScColor& color(colorsToUse[colorName]);
+	if (((color.isSpotColor()) || (color.isRegistrationColor())) && (useSpotColors))
+	{
+		if (!DoSep)
+			PutStream(ToStr(shade / 100.0)+" "+spotMap[colorName] + "\n");
+		else if ((colorName == currentSpot) || (color.isRegistrationColor()))
+			PutStream("0 0 0 "+ToStr(shade / 100.0)+" cmyk\n");
+		else
+			PutStream("0 0 0 0 cmyk\n");
+	}
+	else
+	{
+		int c, m, y, k;
+		SetColor(color, shade, &c, &m, &y, &k, gcr);
+		if (!DoSep || (Plate == 0 || Plate == 1 || Plate == 2 || Plate == 3))
+			PutStream(ToStr(c / 255.0) + " " + ToStr(m / 255.0) + " " + ToStr(y / 255.0) + " " + ToStr(k / 255.0) + " cmyk\n");
+		else
+			PutStream("0 0 0 0 cmyk\n");
+	}
+}
+
 void PSLib::GetBleeds(Page* page, double& left, double& right)
 {
 	MarginStruct values;




More information about the scribus-commit mailing list