summaryrefslogtreecommitdiff
path: root/Build
diff options
context:
space:
mode:
authorAkira Kakuto <kakuto@fuk.kindai.ac.jp>2020-06-26 23:30:45 +0000
committerAkira Kakuto <kakuto@fuk.kindai.ac.jp>2020-06-26 23:30:45 +0000
commit645e537ab44df73df715ea932a63951b0755026a (patch)
tree914821b934aa3b6b553280e9ba3f5fdbdeffe7a1 /Build
parentfdeec2b37fa75c42d82318a293d62182c31bf478 (diff)
Color support extended to support various ColorSpace: Accept an
object reference defining a ColorSpace in color specifications (only for pdf: color commands) (S. Hirata) git-svn-id: svn://tug.org/texlive/trunk@55670 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build')
-rw-r--r--Build/source/texk/dvipdfm-x/ChangeLog9
-rwxr-xr-xBuild/source/texk/dvipdfm-x/configure22
-rw-r--r--Build/source/texk/dvipdfm-x/configure.ac2
-rw-r--r--Build/source/texk/dvipdfm-x/pdfcolor.c429
-rw-r--r--Build/source/texk/dvipdfm-x/pdfcolor.h40
-rw-r--r--Build/source/texk/dvipdfm-x/pdfdoc.c4
-rw-r--r--Build/source/texk/dvipdfm-x/pdfdraw.c27
-rw-r--r--Build/source/texk/dvipdfm-x/spc_util.c256
8 files changed, 450 insertions, 339 deletions
diff --git a/Build/source/texk/dvipdfm-x/ChangeLog b/Build/source/texk/dvipdfm-x/ChangeLog
index 00d87720e64..b9f81c190b8 100644
--- a/Build/source/texk/dvipdfm-x/ChangeLog
+++ b/Build/source/texk/dvipdfm-x/ChangeLog
@@ -1,3 +1,12 @@
+2020-06-27 Shunsaku Hirata <shunsaku.hirata74@gmail.com>
+
+ * pdfcolor.[ch], pdfdoc.c, pdfdraw.c, spc_util.c: An extension
+ to the color support. All color-spaces can be supported (only
+ for pdf: color commands). ColorSpace can be specified by a
+ name key (e.g. DeviceRGB) or an object reference which is a
+ reference to an object defining ColorSpace itself.
+ * configure.ac: Version 20200627.
+
2020-06-24 Akira Kakuto <kakuto@w32tex.org>
* dpxfile.c, pdfximage.c: Remove unnecessary changes on
diff --git a/Build/source/texk/dvipdfm-x/configure b/Build/source/texk/dvipdfm-x/configure
index 2ea1d5aa5be..b92dd53a2df 100755
--- a/Build/source/texk/dvipdfm-x/configure
+++ b/Build/source/texk/dvipdfm-x/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for dvipdfm-x (TeX Live) 20200526.
+# Generated by GNU Autoconf 2.69 for dvipdfm-x (TeX Live) 20200627.
#
# Report bugs to <dvipdfmx@tug.org>.
#
@@ -590,8 +590,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='dvipdfm-x (TeX Live)'
PACKAGE_TARNAME='dvipdfm-x--tex-live-'
-PACKAGE_VERSION='20200526'
-PACKAGE_STRING='dvipdfm-x (TeX Live) 20200526'
+PACKAGE_VERSION='20200627'
+PACKAGE_STRING='dvipdfm-x (TeX Live) 20200627'
PACKAGE_BUGREPORT='dvipdfmx@tug.org'
PACKAGE_URL=''
@@ -1350,7 +1350,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures dvipdfm-x (TeX Live) 20200526 to adapt to many kinds of systems.
+\`configure' configures dvipdfm-x (TeX Live) 20200627 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1421,7 +1421,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of dvipdfm-x (TeX Live) 20200526:";;
+ short | recursive ) echo "Configuration of dvipdfm-x (TeX Live) 20200627:";;
esac
cat <<\_ACEOF
@@ -1551,7 +1551,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-dvipdfm-x (TeX Live) configure 20200526
+dvipdfm-x (TeX Live) configure 20200627
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2390,7 +2390,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by dvipdfm-x (TeX Live) $as_me 20200526, which was
+It was created by dvipdfm-x (TeX Live) $as_me 20200627, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@@ -8077,7 +8077,7 @@ fi
# Define the identity of the package.
PACKAGE='dvipdfm-x--tex-live-'
- VERSION='20200526'
+ VERSION='20200627'
cat >>confdefs.h <<_ACEOF
@@ -14746,7 +14746,7 @@ Usage: $0 [OPTIONS]
Report bugs to <bug-libtool@gnu.org>."
lt_cl_version="\
-dvipdfm-x (TeX Live) config.lt 20200526
+dvipdfm-x (TeX Live) config.lt 20200627
configured by $0, generated by GNU Autoconf 2.69.
Copyright (C) 2011 Free Software Foundation, Inc.
@@ -16636,7 +16636,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by dvipdfm-x (TeX Live) $as_me 20200526, which was
+This file was extended by dvipdfm-x (TeX Live) $as_me 20200627, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -16706,7 +16706,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-dvipdfm-x (TeX Live) config.status 20200526
+dvipdfm-x (TeX Live) config.status 20200627
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
diff --git a/Build/source/texk/dvipdfm-x/configure.ac b/Build/source/texk/dvipdfm-x/configure.ac
index 24b33e03a03..629094a73f6 100644
--- a/Build/source/texk/dvipdfm-x/configure.ac
+++ b/Build/source/texk/dvipdfm-x/configure.ac
@@ -8,7 +8,7 @@ dnl This file is free software; the copyright holder
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl
-AC_INIT([dvipdfm-x (TeX Live)], [20200526], [dvipdfmx@tug.org])
+AC_INIT([dvipdfm-x (TeX Live)], [20200627], [dvipdfmx@tug.org])
AC_PREREQ([2.65])
AC_CONFIG_SRCDIR([agl.c])
AC_CONFIG_AUX_DIR([../../build-aux])
diff --git a/Build/source/texk/dvipdfm-x/pdfcolor.c b/Build/source/texk/dvipdfm-x/pdfcolor.c
index 624480d5e8e..da4be21844f 100644
--- a/Build/source/texk/dvipdfm-x/pdfcolor.c
+++ b/Build/source/texk/dvipdfm-x/pdfcolor.c
@@ -1,6 +1,6 @@
/* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
- Copyright (C) 2002-2019 by Jin-Hwan Cho and Shunsaku Hirata,
+ Copyright (C) 2002-2020 by Jin-Hwan Cho and Shunsaku Hirata,
the dvipdfmx project team.
Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu>
@@ -36,19 +36,16 @@
#include "pdfdoc.h"
#include "pdfdev.h"
+#include "pdfresource.h"
#include "pdfcolor.h"
-/* This function returns PDF_COLORSPACE_TYPE_GRAY,
- * PDF_COLORSPACE_TYPE_RGB, PDF_COLORSPACE_TYPE_CMYK or
- * PDF_COLORSPACE_TYPE_SPOT.
- */
int
pdf_color_type (const pdf_color *color)
{
ASSERT(color);
- return -color->num_components;
+ return color->type;
}
int
@@ -72,6 +69,8 @@ pdf_color_rgbcolor (pdf_color *color, double r, double g, double b)
color->values[1] = g;
color->values[2] = b;
+ color->res_id = -1;
+ color->type = PDF_COLORSPACE_TYPE_RGB;
color->num_components = 3;
color->spot_color_name = NULL;
@@ -107,6 +106,8 @@ pdf_color_cmykcolor (pdf_color *color,
color->values[2] = y;
color->values[3] = k;
+ color->res_id = -1;
+ color->type = PDF_COLORSPACE_TYPE_CMYK;
color->num_components = 4;
color->spot_color_name = NULL;
@@ -126,6 +127,8 @@ pdf_color_graycolor (pdf_color *color, double g)
color->values[0] = g;
+ color->res_id = -1;
+ color->type = PDF_COLORSPACE_TYPE_GRAY;
color->num_components = 1;
color->spot_color_name = NULL;
@@ -146,6 +149,8 @@ pdf_color_spotcolor (pdf_color *color, char* name, double c)
color->values[0] = c;
color->values[1] = 0.0; /* Dummy */
+ color->res_id = -1; /* ??? */
+ color->type = PDF_COLORSPACE_TYPE_SPOT;
color->num_components = 2;
color->spot_color_name = name;
@@ -168,6 +173,12 @@ pdf_color_brighten_color (pdf_color *dst, const pdf_color *src, double f)
{
ASSERT(dst && src);
+ if (dst->type != PDF_COLORSPACE_TYPE_RGB &&
+ dst->type != PDF_COLORSPACE_TYPE_CMYK &&
+ dst->type != PDF_COLORSPACE_TYPE_GRAY) {
+ return;
+ }
+
if (f == 1.0) {
pdf_color_white(dst);
} else {
@@ -183,6 +194,10 @@ pdf_color_brighten_color (pdf_color *dst, const pdf_color *src, double f)
}
}
+/* TODO: remove "is_white"...
+ * pdfdoc.c only use this but not necessary if we have a flag have_bgcolor
+ * to indicate if bg color was set.
+ */
int
pdf_color_is_white (const pdf_color *color)
{
@@ -191,19 +206,19 @@ pdf_color_is_white (const pdf_color *color)
ASSERT(color);
- n = color->num_components;
- switch (n) {
- case 1: /* Gray */
- case 3: /* RGB */
+ switch (color->type) {
+ case PDF_COLORSPACE_TYPE_GRAY:
+ case PDF_COLORSPACE_TYPE_RGB:
f = 1.0;
break;
- case 4: /* CMYK */
+ case PDF_COLORSPACE_TYPE_CMYK:
f = 0.0;
break;
default:
return 0;
}
+ n = color->num_components;
while (n--)
if (color->values[n] != f)
return 0;
@@ -211,60 +226,185 @@ pdf_color_is_white (const pdf_color *color)
return 1;
}
+/* TODO: make_resource_name() in pdfresource.c with configurable prefix. */
int
-pdf_color_to_string (const pdf_color *color, char *buffer, char mask)
+pdf_color_set_color (const pdf_color *color, char *buffer, size_t buffer_len, char mask)
{
- int i, len = 0;
-
- 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));
+ int len = 0;
+ int i;
+
+ {
+ size_t estimate = 0;
+ if (color->num_components > 0) {
+ estimate += 5 * (color->num_components + 1) + 4; /* Assuming color values [0, 1]... */
+ }
+ estimate += strlen(" /DeiceGray CS");
+ if (estimate + 1 > buffer_len) {
+ WARN("Not enough buffer space allocated for writing set_color op...");
+ return 0;
+ }
+ }
+
+ switch (pdf_color_type(color)) {
+ case PDF_COLORSPACE_TYPE_DEVICEGRAY:
+ {
+ len += sprintf(buffer+len, " /DeviceGray %c%c", 'C' | mask, 'S' | mask);
+ for (i = 0; i < color->num_components; i++) {
+ len += sprintf(buffer+len, " %g", ROUND(color->values[i], 0.001));
}
+ len += sprintf(buffer+len, " %c%c", 'S' | mask, 'C' | mask);
+ }
+ break;
+ case PDF_COLORSPACE_TYPE_DEVICERGB:
+ {
+ len += sprintf(buffer+len, " /DeviceRGB %c%c", 'C' | mask, 'S' | mask);
+ for (i = 0; i < color->num_components; i++) {
+ len += sprintf(buffer+len, " %g", ROUND(color->values[i], 0.001));
+ }
+ len += sprintf(buffer+len, " %c%c", 'S' | mask, 'C' | mask);
+ }
+ break;
+ case PDF_COLORSPACE_TYPE_DEVICECMYK:
+ {
+ len += sprintf(buffer+len, " /DeviceCMYK %c%c", 'C' | mask, 'S' | mask);
+ for (i = 0; i < color->num_components; i++) {
+ len += sprintf(buffer+len, " %g", ROUND(color->values[i], 0.001));
+ }
+ len += sprintf(buffer+len, " %c%c", 'S' | mask, 'C' | mask);
+ }
+ break;
+ case PDF_COLORSPACE_TYPE_GRAY:
+ {
+ for (i = 0; i < color->num_components; i++) {
+ len += sprintf(buffer+len, " %g", ROUND(color->values[i], 0.001));
+ }
+ len += sprintf(buffer+len, " %c", 'G' | mask);
+ }
+ break;
+ case PDF_COLORSPACE_TYPE_RGB:
+ {
+ for (i = 0; i < color->num_components; i++) {
+ len += sprintf(buffer+len, " %g", ROUND(color->values[i], 0.001));
+ }
+ len += sprintf(buffer+len, " %c%c", 'R' | mask, 'G' | mask);
+ }
+ break;
+ case PDF_COLORSPACE_TYPE_CMYK:
+ {
+ for (i = 0; i < color->num_components; i++) {
+ len += sprintf(buffer+len, " %g", ROUND(color->values[i], 0.001));
+ }
+ len += sprintf(buffer+len, " %c", 'K' | mask);
+ }
+ break;
+ case PDF_COLORSPACE_TYPE_SPOT:
+ {
+ len = sprintf(buffer+len,
+ " /%s %c%c %g %c%c",
+ color->spot_color_name,
+ 'C' | mask, 'S' | mask,
+ ROUND(color->values[0], 0.001),
+ 'S' | mask, 'C' | mask);
+ }
+ break;
+ case PDF_COLORSPACE_TYPE_CALGRAY:
+ case PDF_COLORSPACE_TYPE_CALRGB:
+ case PDF_COLORSPACE_TYPE_LAB:
+ case PDF_COLORSPACE_TYPE_INDEXED:
+ {
+ char res_name[16];
+
+ snprintf(res_name, 16, "XC%d", color->res_id & 0xffff); /* TODO: Upper 16bits for category ID. See, pdfresource.c */
+ res_name[15] = 0;
+ len += sprintf(buffer+len, " /%s %c%c", res_name, 'C' | mask, 'S' | mask);
+ for (i = 0; i < color->num_components; i++) {
+ len += sprintf(buffer+len, " %g", ROUND(color->values[i], 0.001));
+ }
+ len += sprintf(buffer+len, " %c%c", 'S' | mask, 'C' | mask);
+ pdf_doc_add_page_resource("ColorSpace", res_name, pdf_get_resource_reference(color->res_id));
+ }
+ break;
+ case PDF_COLORSPACE_TYPE_PATTERN:
+ {
+ char res_name[16];
+
+ if (color->res_id < 0) {
+ len += sprintf(buffer+len, " /Pattern %c%c", 'C' | mask, 'S' | mask);
+ /* no color value but just a name */
+ } else {
+ snprintf(res_name, 16, "XC%d", color->res_id & 0xffff); /* TODO: Upper 16bits for category ID. See, pdfresource.c */
+ res_name[15] = 0;
+ len += sprintf(buffer+len, " /%s %c%c", res_name, 'C' | mask, 'S' | mask);
+ for (i = 0; i < color->num_components; i++) {
+ len += sprintf(buffer+len, " %g", ROUND(color->values[i], 0.001));
+ }
+ pdf_doc_add_page_resource("ColorSpace", res_name, pdf_get_resource_reference(color->res_id));
+ }
+ snprintf(res_name, 16, "XP%d", color->pattern_id & 0xffff); /* TODO: see below */
+ res_name[15] = 0;
+ len += sprintf(buffer+len, " /%s %c%c%c", res_name, 'S' | mask, 'C' | mask, 'N' | mask);
+
+ pdf_doc_add_page_resource("Pattern", res_name, pdf_get_resource_reference(color->pattern_id));
+ }
+ break;
+ default:
+ {
+ char res_name[16];
+
+ snprintf(res_name, 8, "CS_%d", color->res_id & 0xffff); /* TODO: Upper 16bits for category ID. See, pdfresource.c */
+ res_name[8] = 0;
+ len += sprintf(buffer+len, " /%s %c%c", res_name, 'C' | mask, 'S' | mask);
+ for (i = 0; i < color->num_components; i++) {
+ len += sprintf(buffer+len, " %g", ROUND(color->values[i], 0.001));
+ }
+ len += sprintf(buffer+len, " %c%c%c", 'S' | mask, 'C' | mask, 'N' | mask);
+ pdf_doc_add_page_resource("ColorSpace", res_name, pdf_get_resource_reference(color->res_id));
+ }
}
return len;
}
pdf_color current_fill = {
+ -1,
+ PDF_COLORSPACE_TYPE_GRAY,
1,
NULL,
- {0.0, 0.0, 0.0, 0.0}
+ {0.0},
+ -1
};
pdf_color current_stroke = {
+ -1,
+ PDF_COLORSPACE_TYPE_GRAY,
1,
NULL,
- {0.0, 0.0, 0.0, 0.0}
+ {0.0},
+ -1
};
/*
* This routine is not a real color matching.
+ * TODO: This can be removed too?
+ * Maybe we are currently always forcing installing color.
*/
int
pdf_color_compare (const pdf_color *color1, const pdf_color *color2)
{
int n;
- n = color1->num_components;
- switch (n) {
- case 1: /* Gray */
- case 2: /* Spot */
- case 3: /* RGB */
- case 4: /* CMYK */
- break;
- default:
+ if (color1->type != PDF_COLORSPACE_TYPE_GRAY ||
+ color1->type != PDF_COLORSPACE_TYPE_RGB ||
+ color1->type != PDF_COLORSPACE_TYPE_CMYK ||
+ color1->type != PDF_COLORSPACE_TYPE_SPOT ||
+ color2->type != PDF_COLORSPACE_TYPE_GRAY ||
+ color2->type != PDF_COLORSPACE_TYPE_RGB ||
+ color2->type != PDF_COLORSPACE_TYPE_CMYK ||
+ color2->type != PDF_COLORSPACE_TYPE_SPOT ||
+ color1->type != color2->type) {
return -1;
}
- if (n != color2->num_components)
- return -1;
-
while (n--)
if (color1->values[n] != color2->values[n])
return -1;
@@ -275,43 +415,14 @@ pdf_color_compare (const pdf_color *color1, const pdf_color *color2)
return 0;
}
-int
-pdf_color_is_valid (const pdf_color *color)
-{
- int n;
-
- n = color->num_components;
- switch (n) {
- case 1: /* Gray */
- case 2: /* Spot */
- case 3: /* RGB */
- case 4: /* CMYK */
- break;
- default:
- return 0;
- }
-
- while (n--)
- if (color->values[n] < 0.0 || color->values[n] > 1.0) {
- WARN("Invalid color value: %g", color->values[n]);
- 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,
+ PDF_COLORSPACE_TYPE_GRAY,
1,
NULL,
- {0.0, 0.0, 0.0, 0.0}
+ {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
+ -1
};
#define DEV_COLOR_STACK_MAX 128
@@ -397,181 +508,9 @@ pdf_dev_preserve_color (void)
#endif
/***************************** COLOR SPACE *****************************/
-
-static int pdf_colorspace_defineresource (const char *ident,
- int subtype,
- void *cdata, pdf_obj *resource);
-
-static int pdf_colorspace_findresource (const char *ident,
- int subtype, const void *cdata);
-
-#if 0
-struct calgray_cdata
-{
- double white_point[3]; /* required, second component must
- * be equal to 1.0
- */
- double black_point[3]; /* optional, default: [0 0 0] */
- double gamma; /* optional, default: 1.0 */
-};
-
-struct calrgb_cdata
-{
- double white_point[3]; /* required, second component must
- * be equal to 1.0
- */
- double black_point[3]; /* optional, default: [0 0 0] */
- double gamma[3]; /* optional, default: [1 1 1] */
- double matrix[9]; /* optional, default: identity
- * [1 0 0 0 1 0 0 0 1]
- */
-};
-
-static void
-release_calrgb (void *cdata)
-{
- struct calrgb_cdata *calrgb;
-
- if (cdata) {
- calrgb = (struct calrgb_cdata *) cdata;
- RELEASE(calrgb);
- }
-}
-
-static int
-compare_calrgb (const char *ident1, const void *cdata1,
- const char *ident2, const void *cdata2)
-{
- struct calrgb_cdata *calrgb1;
- struct calrgb_cdata *calrgb2;
-
- if (ident1 && ident2 &&
- !strcmp(ident1, ident2)) {
- return 0;
- }
-}
-
-static void
-init_calrgb (struct calrgb_cdata *calrgb)
-{
- ASSERT(calrgb);
-
- calrgb->white_point[0] = 1.0;
- calrgb->white_point[1] = 1.0;
- calrgb->white_point[2] = 1.0;
-
- calrgb->black_point[0] = 0.0;
- calrgb->black_point[1] = 0.0;
- calrgb->black_point[2] = 0.0;
-
- calrgb->gamma[0] = 1.0;
- calrgb->gamma[1] = 1.0;
- calrgb->gamma[2] = 1.0;
-
- calrgb->matrix[0] = 1.0;
- calrgb->matrix[1] = 0.0;
- calrgb->matrix[2] = 0.0;
-
- calrgb->matrix[3] = 0.0;
- calrgb->matrix[4] = 1.0;
- calrgb->matrix[5] = 0.0;
-
- calrgb->matrix[6] = 0.0;
- calrgb->matrix[7] = 0.0;
- calrgb->matrix[8] = 1.0;
-}
-
-static int
-valid_calrgb (struct calrgb_cdata *calrgb)
-{
- if (calrgb->white_point[1] != 1.0 ||
- calrgb->white_point[0] <= 0.0 ||
- calrgb->white_point[2] <= 0.0)
- return 0;
-
- if (calrgb->black_point[0] < 0.0 ||
- calrgb->black_point[1] < 0.0 ||
- calrgb->black_point[2] < 0.0)
- return 0;
-
- if (calrgb->gamma[0] < 0.0 ||
- calrgb->gamma[1] < 0.0 ||
- calrgb->gamma[2] < 0.0)
- return 0;
-
- /* matrix should be invertible? */
-
- return 1;
-}
-
-static pdf_obj *
-pdf_color_make_calrgb_resource (struct calrgb_cdata *calrgb)
-{
- pdf_obj *colorspace;
- pdf_obj *calparams, *tmp_array;
-
- ASSERT(calrgb);
-
- if (!valid_calrgb(calrgb))
- return NULL;
-
- colorspace = pdf_new_array();
- calparams = pdf_new_dict();
-
- tmp_array = pdf_new_array();
- pdf_add_array(tmp_array, pdf_new_number(ROUND(calrgb->white_point[0], 0.001)));
- pdf_add_array(tmp_array, pdf_new_number(1.0));
- pdf_add_array(tmp_array, pdf_new_number(ROUND(calrgb->white_point[2], 0.001)));
- pdf_add_dict(calparams, pdf_new_name("WhitePoint"), tmp_array);
-
- if (calrgb->black_point[0] != 0.0 ||
- calrgb->black_point[1] != 0.0 ||
- calrgb->black_point[2] != 0.0) {
- tmp_array = pdf_new_array();
- pdf_add_array(tmp_array, pdf_new_number(ROUND(calrgb->black_point[0], 0.001)));
- pdf_add_array(tmp_array, pdf_new_number(ROUND(calrgb->black_point[1], 0.001)));
- pdf_add_array(tmp_array, pdf_new_number(ROUND(calrgb->black_point[2], 0.001)));
- pdf_add_dict(calparams, pdf_new_name("BlackPoint"), tmp_array);
- }
-
- if (calrgb->gamma[0] != 1.0 ||
- calrgb->gamma[1] != 1.0 ||
- calrgb->gamma[2] != 1.0) {
- tmp_array = pdf_new_array();
- pdf_add_array(tmp_array, pdf_new_number(ROUND(calrgb->gamma[0], 0.001)));
- pdf_add_array(tmp_array, pdf_new_number(ROUND(calrgb->gamma[1], 0.001)));
- pdf_add_array(tmp_array, pdf_new_number(ROUND(calrgb->gamma[2], 0.001)));
- pdf_add_dict(calparams, pdf_new_name("Gamma"), tmp_array);
- }
-
- if (calrgb->matrix[0] != 1.0 ||
- calrgb->matrix[1] != 0.0 ||
- calrgb->matrix[2] != 0.0 ||
- calrgb->matrix[3] != 0.0 ||
- calrgb->matrix[4] != 1.0 ||
- calrgb->matrix[5] != 0.0 ||
- calrgb->matrix[6] != 0.0 ||
- calrgb->matrix[7] != 0.0 ||
- calrgb->matrix[8] != 1.0) {
- tmp_array = pdf_new_array();
- pdf_add_array(tmp_array, pdf_new_number(ROUND(calrgb->matrix[0], 0.001)));
- pdf_add_array(tmp_array, pdf_new_number(ROUND(calrgb->matrix[1], 0.001)));
- pdf_add_array(tmp_array, pdf_new_number(ROUND(calrgb->matrix[2], 0.001)));
- pdf_add_array(tmp_array, pdf_new_number(ROUND(calrgb->matrix[3], 0.001)));
- pdf_add_array(tmp_array, pdf_new_number(ROUND(calrgb->matrix[4], 0.001)));
- pdf_add_array(tmp_array, pdf_new_number(ROUND(calrgb->matrix[5], 0.001)));
- pdf_add_array(tmp_array, pdf_new_number(ROUND(calrgb->matrix[6], 0.001)));
- pdf_add_array(tmp_array, pdf_new_number(ROUND(calrgb->matrix[7], 0.001)));
- pdf_add_array(tmp_array, pdf_new_number(ROUND(calrgb->matrix[8], 0.001)));
- pdf_add_dict(calparams, pdf_new_name("Matrix"), tmp_array);
- }
-
- pdf_add_array(colorspace, pdf_new_name("CalRGB"));
- pdf_add_array(colorspace, calparams);
-
- return colorspace;
-}
-#endif
+/* Currently only for ICCBased color loaded while reading images */
+static int pdf_colorspace_defineresource (const char *ident, int subtype, void *cdata, pdf_obj *resource);
+static int pdf_colorspace_findresource (const char *ident, int subtype, const void *cdata);
static unsigned char nullbytes16[16] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
@@ -746,7 +685,7 @@ get_num_components_iccbased (const struct iccbased_cdata *cdata)
case PDF_COLORSPACE_TYPE_GRAY:
num_components = 1;
break;
- case PDF_COLORSPACE_TYPE_CIELAB:
+ case PDF_COLORSPACE_TYPE_LAB:
num_components = 3;
break;
}
diff --git a/Build/source/texk/dvipdfm-x/pdfcolor.h b/Build/source/texk/dvipdfm-x/pdfcolor.h
index 904a069f24a..cc23396ebc5 100644
--- a/Build/source/texk/dvipdfm-x/pdfcolor.h
+++ b/Build/source/texk/dvipdfm-x/pdfcolor.h
@@ -1,6 +1,6 @@
/* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
- Copyright (C) 2002-2018 by Jin-Hwan Cho and Shunsaku Hirata,
+ Copyright (C) 2002-2020 by Jin-Hwan Cho and Shunsaku Hirata,
the dvipdfmx project team.
Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu>
@@ -25,28 +25,33 @@
#include "pdfobj.h"
-#define PDF_COLORSPACE_TYPE_DEVICECMYK -4
-#define PDF_COLORSPACE_TYPE_DEVICERGB -3
+#define PDF_COLORSPACE_TYPE_CMYK -4
+#define PDF_COLORSPACE_TYPE_RGB -3
#define PDF_COLORSPACE_TYPE_SPOT -2
-#define PDF_COLORSPACE_TYPE_DEVICEGRAY -1
+#define PDF_COLORSPACE_TYPE_GRAY -1
#define PDF_COLORSPACE_TYPE_INVALID 0
-#define PDF_COLORSPACE_TYPE_CALGRAY 1
-#define PDF_COLORSPACE_TYPE_CIELAB 2
-#define PDF_COLORSPACE_TYPE_CALRGB 3
-#define PDF_COLORSPACE_TYPE_ICCBASED 4
-
-#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_COLOR_COMPONENT_MAX 4
+#define PDF_COLORSPACE_TYPE_DEVICEGRAY 1
+#define PDF_COLORSPACE_TYPE_DEVICERGB 2
+#define PDF_COLORSPACE_TYPE_DEVICECMYK 3
+#define PDF_COLORSPACE_TYPE_CALGRAY 4
+#define PDF_COLORSPACE_TYPE_CALRGB 5
+#define PDF_COLORSPACE_TYPE_LAB 6
+#define PDF_COLORSPACE_TYPE_ICCBASED 7
+#define PDF_COLORSPACE_TYPE_SEPARATION 8
+#define PDF_COLORSPACE_TYPE_DEVICEN 9
+#define PDF_COLORSPACE_TYPE_INDEXED 10
+#define PDF_COLORSPACE_TYPE_PATTERN 11
+
+#define PDF_COLOR_COMPONENT_MAX 32
typedef struct
{
+ int res_id;
+ int type;
int num_components;
- char* spot_color_name;
+ char *spot_color_name;
double values[PDF_COLOR_COMPONENT_MAX];
+ int pattern_id;
} pdf_color;
extern int pdf_color_rgbcolor (pdf_color *color,
@@ -66,10 +71,9 @@ 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, char mask);
+extern int pdf_color_set_color (const pdf_color *color, char *buff, size_t buff_len, char mask);
extern int pdf_color_is_white (const pdf_color *color);
-extern int pdf_color_is_valid (const pdf_color *color);
/* Not check size */
extern pdf_obj *iccp_get_rendering_intent (const void *profile, int proflen);
diff --git a/Build/source/texk/dvipdfm-x/pdfdoc.c b/Build/source/texk/dvipdfm-x/pdfdoc.c
index 76a4ada1ccd..6c8f1a446ba 100644
--- a/Build/source/texk/dvipdfm-x/pdfdoc.c
+++ b/Build/source/texk/dvipdfm-x/pdfdoc.c
@@ -1,6 +1,6 @@
/* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
- Copyright (C) 2008-2019 by Jin-Hwan Cho, Matthias Franz, and Shunsaku Hirata,
+ Copyright (C) 2008-2020 by Jin-Hwan Cho, Matthias Franz, and Shunsaku Hirata,
the dvipdfmx project team.
Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu>
@@ -2401,7 +2401,7 @@ pdf_doc_finish_page (pdf_doc *p)
return;
}
-static pdf_color bgcolor = { 1, NULL, { 1.0 } };
+static pdf_color bgcolor = { -1, PDF_COLORSPACE_TYPE_GRAY, 1, NULL, { 1.0 }, -1};
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 ae1ca11c835..1445b6067a5 100644
--- a/Build/source/texk/dvipdfm-x/pdfdraw.c
+++ b/Build/source/texk/dvipdfm-x/pdfdraw.c
@@ -1,6 +1,6 @@
/* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
- Copyright (C) 2002-2018 by Jin-Hwan Cho and Shunsaku Hirata,
+ Copyright (C) 2002-2020 by Jin-Hwan Cho and Shunsaku Hirata,
the dvipdfmx project team.
Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu>
@@ -1256,10 +1256,11 @@ pdf_dev_currentcolor (pdf_color *color, int is_fill)
#endif /* 0 */
/*
+ * FIXME: Please use a macro instead of using 0x20!
* mask == 0 means stroking color, mask == 0x20 nonstroking color
*
* force == 1 means that operators will be generated even if
- * the color is the same as the current graphics state color
+ * the color is the same as the current graphics state color
*/
void
pdf_dev_set_color (const pdf_color *color, char mask, int force)
@@ -1269,34 +1270,16 @@ pdf_dev_set_color (const pdf_color *color, char mask, int force)
pdf_gstate *gs = m_stack_top(&gs_stack);
pdf_color *current = mask ? &gs->fillcolor : &gs->strokecolor;
- ASSERT(pdf_color_is_valid(color));
-
if (!(pdf_dev_get_param(PDF_DEV_PARAM_COLORMODE) &&
- (force || pdf_color_compare(color, current))))
+ (force || pdf_color_compare(color, current))))
/* If "color" is already the current color, then do nothing
* unless a color operator is forced
*/
return;
graphics_mode();
- len = pdf_color_to_string(color, fmt_buf, mask);
- fmt_buf[len++] = ' ';
- switch (pdf_color_type(color)) {
- case PDF_COLORSPACE_TYPE_RGB:
- fmt_buf[len++] = 'R' | mask;
- fmt_buf[len++] = 'G' | mask;
- break;
- case PDF_COLORSPACE_TYPE_CMYK:
- fmt_buf[len++] = 'K' | mask;
- break;
- case PDF_COLORSPACE_TYPE_GRAY:
- fmt_buf[len++] = 'G' | mask;
- break;
- default: /* already verified the given color */
- break;
- }
+ len = pdf_color_set_color(color, fmt_buf, FORMAT_BUFF_LEN, mask);
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 07426a6171e..81bb2e07efb 100644
--- a/Build/source/texk/dvipdfm-x/spc_util.c
+++ b/Build/source/texk/dvipdfm-x/spc_util.c
@@ -1,6 +1,6 @@
/* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
- Copyright (C) 2007-2018 by Jin-Hwan Cho and Shunsaku Hirata,
+ Copyright (C) 2007-2020 by Jin-Hwan Cho and Shunsaku Hirata,
the dvipdfmx project team.
Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks@kettering.edu>
@@ -34,6 +34,7 @@
#include "pdfparse.h"
#include "pdfcolor.h"
#include "pdfdraw.h"
+#include "pdfresource.h"
#include "specials.h"
@@ -191,50 +192,225 @@ spc_read_color_color (struct spc_env *spe, pdf_color *colorspec, struct spc_arg
static int
spc_read_color_pdf (struct spc_env *spe, pdf_color *colorspec, struct spc_arg *ap)
{
- double cv[4]; /* at most four */
- int nc, isarry = 0;
+ double cv[PDF_COLOR_COMPONENT_MAX]; /* dvipdfmx limit */
+ int nc = -1, type = PDF_COLORSPACE_TYPE_INVALID, isarry = 0;
int error = 0;
char *q;
skip_blank(&ap->curptr, ap->endptr);
+ if (ap->curptr[0] == '@') {
+ char *ident = NULL;
+ int res_id = -1;
+ char *name = NULL;
- if (ap->curptr[0] == '[') {
- ap->curptr++; skip_blank(&ap->curptr, ap->endptr);
- isarry = 1;
- }
+ ident = parse_opt_ident(&ap->curptr, ap->endptr);
+ skip_blank(&ap->curptr, ap->endptr);
+ res_id = pdf_findresource("ColorSpace", ident);
+ {
+ pdf_obj *cspace, *csname;
+
+ cspace = spc_lookup_object(ident);
+ if (!cspace || !PDF_OBJ_ARRAYTYPE(cspace)) {
+ WARN("Couldn't find ColorSpace resource for \"@%s\"... (or not an array object?)", ident);
+ RELEASE(ident);
+ return -1;
+ }
+ csname = pdf_get_array(cspace, 0);
+ if (!csname || !PDF_OBJ_NAMETYPE(csname)) {
+ WARN("Invalid ColorSpace resource for \"@%s\" found...", ident);
+ RELEASE(ident);
+ return -1;
+ }
- nc = spc_util_read_numbers(cv, 4, ap);
- switch (nc) {
- case 1:
- pdf_color_graycolor(colorspec, cv[0]);
- break;
- case 3:
- pdf_color_rgbcolor (colorspec, cv[0], cv[1], cv[2]);
- break;
- case 4:
- pdf_color_cmykcolor(colorspec, cv[0], cv[1], cv[2], cv[3]);
- break;
- default:
- /* Try to read the color names defined in dvipsname.def */
- q = parse_c_ident(&ap->curptr, ap->endptr);
- if (!q) {
- spc_warn(spe, "No valid color specified?");
- return -1;
+ name = pdf_name_value(csname);
+ if (!strcmp(name, "Separation")) {
+ type = PDF_COLORSPACE_TYPE_SEPARATION;
+ } else if (!strcmp(name, "CalGray")) {
+ type = PDF_COLORSPACE_TYPE_CALGRAY;
+ nc = 1;
+ } else if (!strcmp(name, "CalRGB")) {
+ type = PDF_COLORSPACE_TYPE_CALRGB;
+ nc = 3;
+ } else if (!strcmp(name, "LAB")) {
+ type = PDF_COLORSPACE_TYPE_LAB;
+ nc = 3;
+ } else if (!strcmp(name, "ICCBased")) {
+ type = PDF_COLORSPACE_TYPE_ICCBASED;
+ nc = -1;
+ } else if (!strcmp(name, "DeviceN")) {
+ type = PDF_COLORSPACE_TYPE_DEVICEN;
+ nc = -1;
+ } else if (!strcmp(name, "Indexed")) {
+ type = PDF_COLORSPACE_TYPE_INDEXED;
+ nc = 1;
+ } else if (!strcmp(name, "Pattern")) {
+ type = PDF_COLORSPACE_TYPE_PATTERN;
+ nc = -1;
+ } else {
+ WARN("Specified object \"%s\" not a ColorSpace???", ident);
+ return -1;
+ }
+ if (res_id < 0) {
+ res_id = pdf_defineresource("ColorSpace", ident, pdf_link_obj(cspace), 0);
+ }
+ RELEASE(ident);
}
- error = pdf_color_namedcolor(colorspec, q);
- if (error)
- spc_warn(spe, "Unrecognized color name: %s, keep the current color", q);
- RELEASE(q);
- break;
- }
-
- if (isarry) {
- skip_blank(&ap->curptr, ap->endptr);
- if (ap->curptr >= ap->endptr || ap->curptr[0] != ']') {
- spc_warn(spe, "Unbalanced '[' and ']' in color specification.");
- error = -1;
+
+ colorspec->res_id = res_id;
+ colorspec->type = type;
+ if (ap->curptr[0] == '[') {
+ ap->curptr++; skip_blank(&ap->curptr, ap->endptr);
+ isarry = 1;
+ }
+ if (nc > 0) {
+ int n;
+ n = spc_util_read_numbers(cv, nc, ap);
+ if (n != nc) {
+ WARN("Wrong number of color components...");
+ return -1;
+ }
} else {
- ap->curptr++;
+ nc = spc_util_read_numbers(cv, PDF_COLOR_COMPONENT_MAX, ap);
+ }
+ colorspec->num_components = nc;
+ while (nc-- > 0) {
+ colorspec->values[nc] = cv[nc];
+ }
+ if (type == PDF_COLORSPACE_TYPE_PATTERN) {
+ /* reference appears */
+ skip_blank(&ap->curptr, ap->endptr);
+ if (ap->curptr[0] != '@') {
+ WARN("An object reference expected but not found for Pattern!");
+ return -1;
+ }
+ ident = parse_opt_ident(&ap->curptr, ap->endptr);
+ res_id = pdf_findresource("Pattern", ident);
+ if (res_id < 0) {
+ pdf_obj *pattern = spc_lookup_object(ident);
+ /* Skip checking. /Type entry is optional... */
+ res_id = pdf_defineresource("Pattern", ident, pdf_link_obj(pattern), 0);
+ }
+ colorspec->pattern_id = res_id;
+ RELEASE(ident);
+ }
+ if (isarry) {
+ skip_blank(&ap->curptr, ap->endptr);
+ if (ap->curptr >= ap->endptr || ap->curptr[0] != ']') {
+ spc_warn(spe, "Unbalanced '[' and ']' or wrong number of color components in color specification?");
+ error = -1;
+ } else {
+ ap->curptr++;
+ }
+ }
+ } else if (ap->curptr[0] == '/') { /* /DeviceGray... */
+ pdf_obj *csname;
+ csname = parse_pdf_name(&ap->curptr, ap->endptr);
+ if (!csname) {
+ WARN("Failed to read a name object while parsing colorspecification...");
+ return -1;
+ } else {
+ char *name = pdf_name_value(csname);
+ if (!strcmp(name, "DeviceGray")) {
+ type = PDF_COLORSPACE_TYPE_DEVICEGRAY;
+ nc = 1;
+ } else if (!strcmp(name, "DeviceRGB")) {
+ type = PDF_COLORSPACE_TYPE_DEVICERGB;
+ nc = 3;
+ } else if (!strcmp(name, "DeviceCMYK")) {
+ type = PDF_COLORSPACE_TYPE_DEVICECMYK;
+ nc = 4;
+ } else if (!strcmp(name, "Pattern")) {
+ type = PDF_COLORSPACE_TYPE_PATTERN;
+ nc = 0;
+ } else {
+ WARN("Unknown ColorSpace name specified: %s", name);
+ return -1;
+ }
+ pdf_release_obj(csname);
+ skip_blank(&ap->curptr, ap->endptr);
+ }
+ colorspec->res_id = -1;
+ colorspec->type = type;
+ if (ap->curptr[0] == '[') {
+ ap->curptr++; skip_blank(&ap->curptr, ap->endptr);
+ isarry = 1;
+ }
+ {
+ int n = spc_util_read_numbers(cv, nc, ap);
+ if (n != nc) {
+ WARN("Wrong number of color components for this ColorSpace...");
+ return -1;
+ }
+ }
+ colorspec->num_components = nc;
+ while (nc-- > 0) {
+ colorspec->values[nc] = cv[nc];
+ }
+ if (type == PDF_COLORSPACE_TYPE_PATTERN) {
+ char *ident = NULL;
+ int res_id = -1;
+ /* reference appears */
+ skip_blank(&ap->curptr, ap->endptr);
+ if (ap->curptr[0] != '@') {
+ WARN("An object reference expected but not found for Pattern!");
+ return -1;
+ }
+ ident = parse_opt_ident(&ap->curptr, ap->endptr);
+ res_id = pdf_findresource("Pattern", ident);
+ if (res_id < 0) {
+ pdf_obj *pattern = spc_lookup_object(ident);
+ /* Skip checking. /Type entry is optional... */
+ res_id = pdf_defineresource("Pattern", ident, pdf_link_obj(pattern), 0);
+ }
+ colorspec->pattern_id = res_id;
+ RELEASE(ident);
+ }
+ if (isarry) {
+ skip_blank(&ap->curptr, ap->endptr);
+ if (ap->curptr >= ap->endptr || ap->curptr[0] != ']') {
+ spc_warn(spe, "Unbalanced '[' and ']' or wrong number of color components in color specification?");
+ error = -1;
+ } else {
+ ap->curptr++;
+ }
+ }
+ } else {
+ if (ap->curptr[0] == '[') {
+ ap->curptr++; skip_blank(&ap->curptr, ap->endptr);
+ isarry = 1;
+ }
+ nc = spc_util_read_numbers(cv, 4, ap);
+ switch (nc) {
+ case 1:
+ pdf_color_graycolor(colorspec, cv[0]);
+ break;
+ case 3:
+ pdf_color_rgbcolor (colorspec, cv[0], cv[1], cv[2]);
+ break;
+ case 4:
+ pdf_color_cmykcolor(colorspec, cv[0], cv[1], cv[2], cv[3]);
+ break;
+ default:
+ /* Try to read the color names defined in dvipsname.def */
+ q = parse_c_ident(&ap->curptr, ap->endptr);
+ if (!q) {
+ spc_warn(spe, "No valid color specified?");
+ return -1;
+ }
+ error = pdf_color_namedcolor(colorspec, q);
+ if (error)
+ spc_warn(spe, "Unrecognized color name: %s, keep the current color", q);
+ RELEASE(q);
+ break;
+ }
+ if (isarry) {
+ skip_blank(&ap->curptr, ap->endptr);
+ if (ap->curptr >= ap->endptr || ap->curptr[0] != ']') {
+ spc_warn(spe, "Unbalanced '[' and ']' in color specification.");
+ error = -1;
+ } else {
+ ap->curptr++;
+ }
}
}
@@ -928,9 +1104,9 @@ spc_util_read_blahblah (struct spc_env *spe,
#ifdef cmyk
#undef cmyk
#endif
-#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)}}
+#define gray(g) {-1, PDF_COLORSPACE_TYPE_GRAY, 1, NULL, {g}, -1}
+#define rgb8(r,g,b) {-1, PDF_COLORSPACE_TYPE_RGB, 3, NULL, {((r)/255.0), ((g)/255.0), ((b)/255.0), 0.0}, -1}
+#define cmyk(c,m,y,k) {-1, PDF_COLORSPACE_TYPE_CMYK, 4, NULL, {(c), (m), (y), (k)}, -1}
static struct colordef_
{