summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/xelatex/xespotcolor/PATCHES
blob: ce25525c7ef947c60e462d26e2e0946af05fbe30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
--- pdfcolor.c.orig	2014-07-30 22:27:05.423428483 +0300
+++ pdfcolor.c	2014-08-13 22:59:53.862311266 +0300
@@ -27,6 +27,7 @@
 #include <config.h>
 #endif
 
+#include <strings.h>
 #include "system.h"
 #include "mem.h"
 #include "error.h"
@@ -79,6 +80,8 @@
 
   color->num_components = 3;
 
+  bzero(color->SpotColorName, 256); 
+
   return 0;
 }
 
@@ -112,6 +115,7 @@
 
   color->num_components = 4;
 
+  bzero(color->SpotColorName, 256); 
   return 0;
 }
 
@@ -129,6 +133,27 @@
 
   color->num_components = 1;
 
+  bzero(color->SpotColorName, 256); 
+
+  return 0;
+}
+
+int
+pdf_color_spotcolor (pdf_color *color, char* spot_color_name, double c)
+{
+  ASSERT(color);
+
+  if (c < 0.0 || c > 1.0) {
+    WARN("Invalid color value specified: grade=%g", c);
+    return -1;
+  }
+
+  color->values[0] = c;
+
+  color->num_components = 2;
+
+  strcpy(color->SpotColorName, spot_color_name);
+
   return 0;
 }
 
@@ -190,24 +215,35 @@
   return 1;
 }
 
-int
-pdf_color_to_string (const pdf_color *color, char *buffer)
+int 
+pdf_color_to_string (const pdf_color *color, char *buffer, char mask)
 {
   int i, len = 0;
 
-  for (i = 0; i < color->num_components; i++) {
-    len += sprintf(buffer+len, " %g", ROUND(color->values[i], 0.001));
+  if ( (-color->num_components) == PDF_COLORSPACE_TYPE_SPOT ) {
+    if (mask == '0') {
+      len += sprintf(buffer+len, " /%s CS %g SC", color->SpotColorName, ROUND(color->values[0], 0.001));
+    }
+    else {
+      len += sprintf(buffer+len, " /%s cs %g sc", color->SpotColorName, ROUND(color->values[0], 0.001));
+    }
   }
+  else {
+     for (i = 0; i < color->num_components; i++) {
+       len += sprintf(buffer+len, " %g", ROUND(color->values[i], 0.001));    
+      }
+  }
+ 
   return len;
 }
 
 pdf_color current_fill   = {
-  1,
+  1, {'\0'},
   {0.0, 0.0, 0.0, 0.0}
 };
 
 pdf_color current_stroke = {
-  1,
+  1, {'\0'},
   {0.0, 0.0, 0.0, 0.0}
 };
 
@@ -244,6 +280,9 @@
 {
   int  n;
 
+  if ( color->SpotColorName[0] != '\0' ) 
+    return 1;
+
   n = color->num_components;
   switch (n) {
   case 1:  /* Gray */
@@ -265,7 +304,7 @@
 
 /* Dvipdfm special */
 pdf_color default_color = {
-  1,
+  1, {'\0'},
   {0.0, 0.0, 0.0, 0.0}
 };
 
--- pdfcolor.h.orig	2014-07-24 21:57:12.649698246 +0300
+++ pdfcolor.h	2014-08-06 23:31:39.430330177 +0300
@@ -37,6 +37,7 @@
 #define PDF_COLORSPACE_TYPE_CMYK  PDF_COLORSPACE_TYPE_DEVICECMYK
 #define PDF_COLORSPACE_TYPE_RGB   PDF_COLORSPACE_TYPE_DEVICERGB
 #define PDF_COLORSPACE_TYPE_GRAY  PDF_COLORSPACE_TYPE_DEVICEGRAY
+#define PDF_COLORSPACE_TYPE_SPOT  -2
 
 
 #define PDF_COLOR_COMPONENT_MAX 4
@@ -44,6 +45,7 @@
 typedef struct
 {
   int    num_components;
+  char   SpotColorName[255];
   double values[PDF_COLOR_COMPONENT_MAX];
 } pdf_color;
 
@@ -54,6 +56,9 @@
 extern int        pdf_color_cmykcolor     (pdf_color *color,
                                            double c, double m, double y, double k);
 extern int        pdf_color_graycolor     (pdf_color *color, double g);
+
+extern int        pdf_color_spotcolor     (pdf_color *color, 
+                                           char* spot_color_name, double c);
 extern void       pdf_color_copycolor     (pdf_color *color1, const pdf_color *color2);
 
 #define pdf_color_black(c)   pdf_color_graycolor(c, 0.0);
@@ -63,7 +68,7 @@
 
 extern int        pdf_color_type          (const pdf_color *color);
 extern int        pdf_color_compare       (const pdf_color *color1, const pdf_color *color2);
-extern int        pdf_color_to_string     (const pdf_color *color, char *buffer);
+extern int        pdf_color_to_string     (const pdf_color *color, char *buffer, char mask);
 
 extern int        pdf_color_is_white      (const pdf_color *color);
 extern int        pdf_color_is_valid      (const pdf_color *color);
--- pdfdraw.c.orig	2014-08-01 23:26:17.454362614 +0300
+++ pdfdraw.c	2014-08-13 22:56:05.927819086 +0300
@@ -1260,7 +1260,7 @@
  *   the color is the same as the current graphics state color
  */
 void
-pdf_dev_set_color (const pdf_color *color, char mask, int force)
+pdf_dev_set_color (const pdf_color *color, char mask, int force)   
 {
   int len;
 
@@ -1269,7 +1269,7 @@
 
   ASSERT(pdf_color_is_valid(color));
 
-  if (!(pdf_dev_get_param(PDF_DEV_PARAM_COLORMODE) &&
+  if (!(pdf_dev_get_param(PDF_DEV_PARAM_COLORMODE) &&             
 	(force || pdf_color_compare(color, current))))
     /* If "color" is already the current color, then do nothing
      * unless a color operator is forced
@@ -1277,7 +1277,7 @@
     return;
 
   graphics_mode();
-  len = pdf_color_to_string(color, fmt_buf);
+  len = pdf_color_to_string(color, fmt_buf, mask);
   fmt_buf[len++] = ' ';
   switch (pdf_color_type(color)) {
   case  PDF_COLORSPACE_TYPE_RGB:
@@ -1293,7 +1293,7 @@
   default: /* already verified the given color */
     break;
   }
-  pdf_doc_add_page_content(fmt_buf, len);  /* op: RG K G rg k g */
+  pdf_doc_add_page_content(fmt_buf, len);  /* op: RG K G rg k g etc. */
 
   pdf_color_copycolor(current, color);
 }
--- spc_util.c.orig	2014-07-17 16:35:39.531113864 +0300
+++ spc_util.c	2014-08-04 23:29:53.857556810 +0300
@@ -38,7 +38,6 @@
 
 #include "spc_util.h"
 
-
 #ifndef ISBLANK
 #define ISBLANK(c) ((c) == ' ' || (c) == '\t')
 #endif
@@ -111,6 +110,7 @@
 spc_read_color_color (struct spc_env *spe, pdf_color *colorspec, struct spc_arg *ap)
 {
   char    *q;
+  char    *spotColorName;
   double   cv[4];
   int      nc;
   int      error = 0;
@@ -146,6 +146,20 @@
     } else {
       pdf_color_graycolor(colorspec, cv[0]);
     }
+  } else if (!strcmp(q, "spot")) { /* Handle spot colors */  
+    spotColorName = parse_c_ident(&ap->curptr, ap->endptr);
+    if (!spotColorName) {
+      spc_warn(spe, "No valid spot color name specified?");
+      return  -1;
+    }
+    skip_blank(&ap->curptr, ap->endptr);
+    nc = spc_util_read_numbers(cv, 1, spe, ap);
+    if (nc != 1) {
+      spc_warn(spe, "Invalid value for spot color specification.");
+      error = -1;
+    } else {
+      pdf_color_spotcolor(colorspec, spotColorName, cv[0]);
+    } 
   } else if (!strcmp(q, "hsb")) {
     nc = spc_util_read_numbers(cv, 3, spe, ap);
     if (nc != 3) {
@@ -236,7 +250,6 @@
   if (ap->curptr >= ap->endptr) {
     return -1;
   }
-
   if (syntax)
     return spc_read_color_color(spe, colorspec, ap);
   else