summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Build/source/texk/dvipdfm-x/ChangeLog5
-rw-r--r--Build/source/texk/dvipdfm-x/pdfcolor.c63
-rw-r--r--Build/source/texk/dvipdfm-x/pdfcolor.h7
-rw-r--r--Build/source/texk/dvipdfm-x/pdfdoc.c2
-rw-r--r--Build/source/texk/dvipdfm-x/pdfdraw.c4
-rw-r--r--Build/source/texk/dvipdfm-x/spc_util.c21
6 files changed, 91 insertions, 11 deletions
diff --git a/Build/source/texk/dvipdfm-x/ChangeLog b/Build/source/texk/dvipdfm-x/ChangeLog
index f119a9ba295..f98a5a3d952 100644
--- a/Build/source/texk/dvipdfm-x/ChangeLog
+++ b/Build/source/texk/dvipdfm-x/ChangeLog
@@ -1,3 +1,8 @@
+2015-03-17 Khaled Hosny <khaledhosny@eglug.org>
+
+ * pdfcolor.c, pdfcolor.h, pdfdoc.c, pdfdraw.c, spc_util.c: Add sopt
+ colors support, based on patch by Apostolos Syropoulos.
+
2015-03-15 Khaled Hosny <khaledhosny@eglug.org>
* tests/*.{bb,xbb}: Update version number.
diff --git a/Build/source/texk/dvipdfm-x/pdfcolor.c b/Build/source/texk/dvipdfm-x/pdfcolor.c
index 140c5c5aa52..8eb847e77b3 100644
--- a/Build/source/texk/dvipdfm-x/pdfcolor.c
+++ b/Build/source/texk/dvipdfm-x/pdfcolor.c
@@ -46,7 +46,8 @@ pdf_color_set_verbose (void)
}
/* This function returns PDF_COLORSPACE_TYPE_GRAY,
- * PDF_COLORSPACE_TYPE_RGB or PDF_COLORSPACE_TYPE_CMYK.
+ * PDF_COLORSPACE_TYPE_RGB, PDF_COLORSPACE_TYPE_CMYK or
+ * PDF_COLORSPACE_TYPE_SPOT.
*/
int
pdf_color_type (const pdf_color *color)
@@ -79,6 +80,8 @@ pdf_color_rgbcolor (pdf_color *color, double r, double g, double b)
color->num_components = 3;
+ color->spot_color_name = NULL;
+
return 0;
}
@@ -112,6 +115,8 @@ pdf_color_cmykcolor (pdf_color *color,
color->num_components = 4;
+ color->spot_color_name = NULL;
+
return 0;
}
@@ -129,6 +134,28 @@ pdf_color_graycolor (pdf_color *color, double g)
color->num_components = 1;
+ color->spot_color_name = NULL;
+
+ return 0;
+}
+
+int
+pdf_color_spotcolor (pdf_color *color, char* 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->values[1] = 0.0; /* Dummy */
+
+ color->num_components = 2;
+
+ color->spot_color_name = name;
+
return 0;
}
@@ -191,23 +218,34 @@ pdf_color_is_white (const pdf_color *color)
}
int
-pdf_color_to_string (const pdf_color *color, char *buffer)
+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 (pdf_color_type(color) == PDF_COLORSPACE_TYPE_SPOT) {
+ len = sprintf(buffer, " /%s %c%c %g %c%c",
+ color->spot_color_name,
+ 'C' | mask, 'S' | mask,
+ ROUND(color->values[0], 0.001),
+ 'S' | mask, 'C' | mask);
+ } 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,
+ NULL,
{0.0, 0.0, 0.0, 0.0}
};
pdf_color current_stroke = {
1,
+ NULL,
{0.0, 0.0, 0.0, 0.0}
};
@@ -222,6 +260,7 @@ pdf_color_compare (const pdf_color *color1, const pdf_color *color2)
n = color1->num_components;
switch (n) {
case 1: /* Gray */
+ case 2: /* Spot */
case 3: /* RGB */
case 4: /* CMYK */
break;
@@ -236,6 +275,9 @@ pdf_color_compare (const pdf_color *color1, const pdf_color *color2)
if (color1->values[n] != color2->values[n])
return -1;
+ if (color1->spot_color_name && color2->spot_color_name)
+ return strcmp(color1->spot_color_name, color2->spot_color_name);
+
return 0;
}
@@ -247,6 +289,7 @@ pdf_color_is_valid (const pdf_color *color)
n = color->num_components;
switch (n) {
case 1: /* Gray */
+ case 2: /* Spot */
case 3: /* RGB */
case 4: /* CMYK */
break;
@@ -260,12 +303,20 @@ pdf_color_is_valid (const pdf_color *color)
return 0;
}
+ if (pdf_color_type(color) == PDF_COLORSPACE_TYPE_SPOT) {
+ if (!color->spot_color_name || color->spot_color_name[0] == '\0') {
+ WARN("Invalid spot color: empty name");
+ return 0;
+ }
+ }
+
return 1;
}
/* Dvipdfm special */
pdf_color default_color = {
1,
+ NULL,
{0.0, 0.0, 0.0, 0.0}
};
@@ -291,6 +342,10 @@ pdf_color_clear_stack (void)
if (color_stack.current > 0) {
WARN("You've mistakenly made a global color change within nested colors.");
}
+ while (color_stack.current--) {
+ free(color_stack.stroke[color_stack.current].spot_color_name);
+ free(color_stack.fill[color_stack.current].spot_color_name);
+ }
color_stack.current = 0;
pdf_color_black(color_stack.stroke);
pdf_color_black(color_stack.fill);
diff --git a/Build/source/texk/dvipdfm-x/pdfcolor.h b/Build/source/texk/dvipdfm-x/pdfcolor.h
index 34a3399925b..31dd4ff51b9 100644
--- a/Build/source/texk/dvipdfm-x/pdfcolor.h
+++ b/Build/source/texk/dvipdfm-x/pdfcolor.h
@@ -27,6 +27,7 @@
#define PDF_COLORSPACE_TYPE_DEVICECMYK -4
#define PDF_COLORSPACE_TYPE_DEVICERGB -3
+#define PDF_COLORSPACE_TYPE_SPOT -2
#define PDF_COLORSPACE_TYPE_DEVICEGRAY -1
#define PDF_COLORSPACE_TYPE_INVALID 0
#define PDF_COLORSPACE_TYPE_CALGRAY 1
@@ -44,6 +45,7 @@
typedef struct
{
int num_components;
+ char* spot_color_name;
double values[PDF_COLOR_COMPONENT_MAX];
} pdf_color;
@@ -54,6 +56,9 @@ extern int pdf_color_rgbcolor (pdf_color *color,
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* 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 void pdf_color_brighten_color (pdf_color *dst, const pdf_color *src
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);
diff --git a/Build/source/texk/dvipdfm-x/pdfdoc.c b/Build/source/texk/dvipdfm-x/pdfdoc.c
index 6717995298e..d138fda8413 100644
--- a/Build/source/texk/dvipdfm-x/pdfdoc.c
+++ b/Build/source/texk/dvipdfm-x/pdfdoc.c
@@ -2279,7 +2279,7 @@ pdf_doc_finish_page (pdf_doc *p)
return;
}
-static pdf_color bgcolor = { 1, { 1.0 } };
+static pdf_color bgcolor = { 1, NULL, { 1.0 } };
void
pdf_doc_set_bgcolor (const pdf_color *color)
diff --git a/Build/source/texk/dvipdfm-x/pdfdraw.c b/Build/source/texk/dvipdfm-x/pdfdraw.c
index e81839cce09..9d9348cc811 100644
--- a/Build/source/texk/dvipdfm-x/pdfdraw.c
+++ b/Build/source/texk/dvipdfm-x/pdfdraw.c
@@ -1277,7 +1277,7 @@ pdf_dev_set_color (const pdf_color *color, char mask, int force)
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 @@ pdf_dev_set_color (const pdf_color *color, char mask, int force)
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);
}
diff --git a/Build/source/texk/dvipdfm-x/spc_util.c b/Build/source/texk/dvipdfm-x/spc_util.c
index ad2d7468c03..3ebfff6c1ed 100644
--- a/Build/source/texk/dvipdfm-x/spc_util.c
+++ b/Build/source/texk/dvipdfm-x/spc_util.c
@@ -145,6 +145,21 @@ spc_read_color_color (struct spc_env *spe, pdf_color *colorspec, struct spc_arg
} else {
pdf_color_graycolor(colorspec, cv[0]);
}
+ } else if (!strcmp(q, "spot")) { /* Handle spot colors */
+ char *color_name = parse_c_ident(&ap->curptr, ap->endptr);
+ if (!color_name) {
+ spc_warn(spe, "No valid spot color name specified?");
+ return -1;
+ }
+ skip_blank(&ap->curptr, ap->endptr);
+ nc = spc_util_read_numbers(cv, 1, ap);
+ if (nc != 1) {
+ spc_warn(spe, "Invalid value for spot color specification.");
+ error = -1;
+ free(color_name);
+ } else {
+ pdf_color_spotcolor(colorspec, color_name, cv[0]);
+ }
} else if (!strcmp(q, "hsb")) {
nc = spc_util_read_numbers(cv, 3, ap);
if (nc != 3) {
@@ -704,9 +719,9 @@ spc_util_read_dimtrns (struct spc_env *spe, transform_info *ti, struct spc_arg *
#ifdef cmyk
#undef cmyk
#endif
-#define gray(g) {1, {g}}
-#define rgb8(r,g,b) {3, {((r)/255.0), ((g)/255.0), ((b)/255.0), 0.0}}
-#define cmyk(c,m,y,k) {4, {(c), (m), (y), (k)}}
+#define gray(g) {1, NULL, {g}}
+#define rgb8(r,g,b) {3, NULL, {((r)/255.0), ((g)/255.0), ((b)/255.0), 0.0}}
+#define cmyk(c,m,y,k) {4, NULL, {(c), (m), (y), (k)}}
static struct colordef_
{