summaryrefslogtreecommitdiff
path: root/Build/source
diff options
context:
space:
mode:
authorAkira Kakuto <kakuto@fuk.kindai.ac.jp>2020-09-06 04:59:35 +0000
committerAkira Kakuto <kakuto@fuk.kindai.ac.jp>2020-09-06 04:59:35 +0000
commit77d33a75930c5bc87f8010d9a7cec19c45eace36 (patch)
tree22bcd66248013317a80179e4c561923ebf4f5af6 /Build/source
parent1d1f20653e5f584e1ef8882796de7273c2604d9e (diff)
Add a new special pdfcolorstack. (S. Hirata)
git-svn-id: svn://tug.org/texlive/trunk@56274 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source')
-rw-r--r--Build/source/texk/dvipdfm-x/ChangeLog10
-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/spc_misc.c373
-rw-r--r--Build/source/texk/dvipdfm-x/spc_misc.h8
-rw-r--r--Build/source/texk/dvipdfm-x/spc_pdfm.c87
-rw-r--r--Build/source/texk/dvipdfm-x/specials.c64
-rw-r--r--Build/source/texk/dvipdfm-x/specials.h3
8 files changed, 502 insertions, 67 deletions
diff --git a/Build/source/texk/dvipdfm-x/ChangeLog b/Build/source/texk/dvipdfm-x/ChangeLog
index 31948578624..6da4c586f91 100644
--- a/Build/source/texk/dvipdfm-x/ChangeLog
+++ b/Build/source/texk/dvipdfm-x/ChangeLog
@@ -1,3 +1,13 @@
+2020-09-06 Shunsaku Hirata <shunsaku.hirata74@gmail.com>
+
+ * spc_pdfm.c: pdf:bcolor and pdf:scolor now accept new
+ keywords "fill" and "stroke" to indicate either of fill/stroke
+ color is specified.
+ * spc_misc.[ch], specials.[ch]: New special commands for
+ pdfcolorstack are added. This is a compatibility feature to
+ pdfcolorstack in pdftex.
+ * configure.ac: Version 20200906.
+
2020-09-05 Shunsaku Hirata <shunsaku.hirata74@gmail.com>
* spc_pdfm.c: Workaround for an issue that occurs when an
diff --git a/Build/source/texk/dvipdfm-x/configure b/Build/source/texk/dvipdfm-x/configure
index f2025851e08..96006213388 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) 20200905.
+# Generated by GNU Autoconf 2.69 for dvipdfm-x (TeX Live) 20200906.
#
# 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='20200905'
-PACKAGE_STRING='dvipdfm-x (TeX Live) 20200905'
+PACKAGE_VERSION='20200906'
+PACKAGE_STRING='dvipdfm-x (TeX Live) 20200906'
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) 20200905 to adapt to many kinds of systems.
+\`configure' configures dvipdfm-x (TeX Live) 20200906 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) 20200905:";;
+ short | recursive ) echo "Configuration of dvipdfm-x (TeX Live) 20200906:";;
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 20200905
+dvipdfm-x (TeX Live) configure 20200906
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 20200905, which was
+It was created by dvipdfm-x (TeX Live) $as_me 20200906, 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='20200905'
+ VERSION='20200906'
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 20200905
+dvipdfm-x (TeX Live) config.lt 20200906
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 20200905, which was
+This file was extended by dvipdfm-x (TeX Live) $as_me 20200906, 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 20200905
+dvipdfm-x (TeX Live) config.status 20200906
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 78faac00e6f..38bc50dddc0 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)], [20200905], [dvipdfmx@tug.org])
+AC_INIT([dvipdfm-x (TeX Live)], [20200906], [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/spc_misc.c b/Build/source/texk/dvipdfm-x/spc_misc.c
index 87678486f99..9b9c7a7d9bf 100644
--- a/Build/source/texk/dvipdfm-x/spc_misc.c
+++ b/Build/source/texk/dvipdfm-x/spc_misc.c
@@ -32,6 +32,8 @@
#include "mfileio.h"
+#include "dpxutil.h"
+
#include "pdfparse.h"
#include "pdfobj.h"
@@ -47,6 +49,340 @@
#include "spc_util.h"
#include "spc_misc.h"
+/* pdfcolorstack:
+ * This special is provoded as a compatibility feature to pdftex.
+ */
+struct stack
+{
+ int page;
+ int direct;
+ dpx_stack stack;
+};
+
+#define PDFCOLORSTACK_MAX_STACK 256
+struct spc_stack
+{
+ struct stack stacks[PDFCOLORSTACK_MAX_STACK];
+};
+
+static struct spc_stack spc_stack;
+
+static int
+pdfcolorstack__get_id (struct spc_env *spe, int *id, struct spc_arg *args)
+{
+ char *q;
+
+ if (args->curptr >= args->endptr) {
+ spc_warn(spe, "Stack ID number expected but not found.");
+ return -1;
+ }
+ q = parse_number(&args->curptr, args->endptr);
+ if (!q) {
+ spc_warn(spe, "Stack ID number expected but not found.");
+ return -1;
+ }
+ *id = atoi(q);
+ RELEASE(q);
+
+ skip_white(&args->curptr, args->endptr);
+
+ return 0;
+}
+
+static int
+pdfcolorstack__init (void *dp)
+{
+ struct spc_stack *sd = dp;
+ int i;
+
+ for (i = 0; i < 64; i++) {
+ sd->stacks[i].page = 0;
+ sd->stacks[i].direct = 0;
+ dpx_stack_init(&sd->stacks[i].stack);
+ }
+
+ return 0;
+}
+
+static int
+pdfcolorstack__clean (void *dp)
+{
+ struct spc_stack *sd = dp;
+ int i;
+
+ for (i = 0; i < PDFCOLORSTACK_MAX_STACK; i++) {
+ pdf_obj *litstr;
+ dpx_stack *stk = &sd->stacks[i].stack;
+
+ while ((litstr = dpx_stack_pop(stk)) != NULL) {
+ pdf_release_obj(litstr);
+ }
+ }
+
+ return 0;
+}
+
+static void
+pdfcolorstack__set_litstr (pdf_coord cp, pdf_obj *litstr, int direct)
+{
+ pdf_tmatrix M;
+
+ if (!litstr)
+ return;
+
+ if (!direct) {
+ M.a = M.d = 1.0; M.b = M.c = 0.0;
+ M.e = cp.x; M.f = cp.y;
+ pdf_dev_concat(&M);
+ }
+ pdf_doc_add_page_content(" ", 1);
+ pdf_doc_add_page_content(pdf_string_value(litstr), pdf_string_length(litstr));
+ if (!direct) {
+ M.e = -cp.x; M.f = -cp.y;
+ pdf_dev_concat(&M);
+ }
+}
+
+static int
+spc_handler_pdfcolorstackinit (struct spc_env *spe, struct spc_arg *args)
+{
+ int id = -1;
+ struct stack *st;
+ char *q;
+ pdf_coord cp = {0.0, 0.0};
+ pdf_obj *litstr;
+
+ skip_white(&args->curptr, args->endptr);
+ if (args->curptr >= args->endptr)
+ return -1;
+
+ if (pdfcolorstack__get_id(spe, &id, args) < 0)
+ return -1;
+ if (id < 0 || id >= PDFCOLORSTACK_MAX_STACK) {
+ spc_warn(spe, "Invalid stack number specified: %d", id);
+ return -1;
+ }
+ skip_white(&args->curptr, args->endptr);
+
+ st = &spc_stack.stacks[id];
+ if (dpx_stack_depth(&st->stack) > 0) {
+ spc_warn(spe, "Stadk ID=%d already initialized?", id);
+ return -1;
+ }
+
+ while ((q = parse_c_ident(&args->curptr, args->endptr)) != NULL) {
+ if (!strcmp(q, "page")) {
+ st->page = 1;
+ } else if (!strcmp(q, "direct")) {
+ st->direct = 1;
+ } else {
+ spc_warn(spe, "Ignoring unknown option for pdfcolorstack special (init): %s", q);
+ }
+ RELEASE(q);
+ skip_white(&args->curptr, args->endptr);
+ }
+
+ if (args->curptr < args->endptr) {
+ litstr = parse_pdf_string(&args->curptr, args->endptr);
+ if (litstr) {
+ dpx_stack_push(&st->stack, litstr);
+ pdfcolorstack__set_litstr(cp, litstr, st->direct);
+ }
+ skip_white(&args->curptr, args->endptr);
+ } else {
+ spc_warn(spe, "No valid PDF literal specified.");
+ return -1;
+ }
+
+ return 0;
+}
+
+static int
+pdfcolorstack__set (struct spc_env *spe, struct stack *st, pdf_coord cp, struct spc_arg *args)
+{
+ pdf_obj *litstr;
+
+ skip_white(&args->curptr, args->endptr);
+ if (args->curptr >= args->endptr)
+ return -1;
+
+ litstr = dpx_stack_pop(&st->stack);
+ if (!litstr) {
+ spc_warn(spe, "Stack empty!");
+ return -1;
+ }
+ pdf_release_obj(litstr);
+
+ litstr = parse_pdf_string(&args->curptr, args->endptr);
+ if (litstr) {
+ dpx_stack_push(&st->stack, litstr);
+ pdfcolorstack__set_litstr(cp, litstr, st->direct);
+ skip_white(&args->curptr, args->endptr);
+ }
+
+ return 0;
+}
+
+static int
+pdfcolorstack__push (struct spc_env *spe, struct stack *st, pdf_coord cp, struct spc_arg *args)
+{
+ pdf_obj *litstr;
+
+ skip_white(&args->curptr, args->endptr);
+ if (args->curptr >= args->endptr)
+ return -1;
+
+ litstr = parse_pdf_string(&args->curptr, args->endptr);
+ if (litstr) {
+ dpx_stack_push(&st->stack, litstr);
+ pdfcolorstack__set_litstr(cp, litstr, st->direct);
+ skip_white(&args->curptr, args->endptr);
+ }
+
+ return 0;
+}
+
+static int
+pdfcolorstack__current (struct spc_env *spe, struct stack *st, pdf_coord cp, struct spc_arg *args)
+{
+ pdf_obj *litstr;
+
+ litstr = dpx_stack_top(&st->stack);
+ if (litstr) {
+ pdfcolorstack__set_litstr(cp, litstr, st->direct);
+ skip_white(&args->curptr, args->endptr);
+ } else {
+ spc_warn(spe, "Stack empty!");
+ return -1;
+ }
+
+ return 0;
+}
+
+static int
+pdfcolorstack__pop (struct spc_env *spe, struct stack *st, pdf_coord cp, struct spc_arg *args)
+{
+ int error = 0;
+ pdf_obj *litstr;
+
+ /* "default" at the bottom */
+ if (dpx_stack_depth(&st->stack) < 2) {
+ spc_warn(spe, "Stack underflow");
+ return -1;
+ }
+ litstr = dpx_stack_pop(&st->stack);
+ if (litstr) {
+ pdf_release_obj(litstr);
+ }
+ litstr = dpx_stack_top(&st->stack);
+ if (litstr) {
+ pdfcolorstack__set_litstr(cp, litstr, st->direct);
+ }
+
+ return error;
+}
+
+static int
+spc_handler_pdfcolorstack (struct spc_env *spe, struct spc_arg *args)
+{
+ int error = 0;
+ int id;
+ char *command;
+ struct stack *st;
+ pdf_coord cp;
+
+ skip_white(&args->curptr, args->endptr);
+ if (args->curptr >= args->endptr)
+ return -1;
+
+ if (pdfcolorstack__get_id(spe, &id, args) < 0)
+ return -1;
+ if (id < 0 || id >= PDFCOLORSTACK_MAX_STACK) {
+ spc_warn(spe, "Invalid stack ID specified: %d", id);
+ return -1;
+ }
+ skip_white(&args->curptr, args->endptr);
+
+ st = &spc_stack.stacks[id];
+ if (dpx_stack_depth(&st->stack) < 1) {
+ spc_warn(spe, "Stack ID=%d not properly initialized?", id);
+ return -1;
+ }
+
+ command = parse_c_ident(&args->curptr, args->endptr);
+ if (!command)
+ return -1;
+
+ spc_get_current_point(spe, &cp);
+ if (!strcmp(command, "set")) {
+ error = pdfcolorstack__set(spe, st, cp, args);
+ } else if (!strcmp(command, "push")) {
+ error = pdfcolorstack__push(spe, st, cp, args);
+ } else if (!strcmp(command, "pop")) {
+ error = pdfcolorstack__pop(spe, st, cp, args);
+ } else if (!strcmp(command, "current")) {
+ error = pdfcolorstack__current(spe, st, cp, args);
+ } else {
+ spc_warn(spe, "Unknown action: %s", command);
+ }
+
+ if (error) {
+ spc_warn(spe, "Error occurred while processing pdfcolorstack: id=%d command=\"%s\"", id, command);
+ }
+
+ RELEASE(command);
+
+ return error;
+}
+
+
+int
+spc_misc_at_begin_document (void)
+{
+ struct spc_stack *sd = &spc_stack;
+ return pdfcolorstack__init(sd);
+}
+
+int
+spc_misc_at_end_document (void)
+{
+ struct spc_stack *sd = &spc_stack;
+ return pdfcolorstack__clean(sd);
+}
+
+int
+spc_misc_at_begin_page (void)
+{
+ struct spc_stack *sd = &spc_stack;
+ int i;
+
+ for (i = 0; i < 64; i++) {
+ dpx_stack *stk = &sd->stacks[i].stack;
+
+ if (sd->stacks[i].page) {
+ pdf_obj *litstr = dpx_stack_top(stk);
+ pdf_coord cp = {0.0, 0.0};
+
+ if (litstr)
+ pdfcolorstack__set_litstr(cp, litstr, sd->stacks[i].direct);
+ }
+ }
+
+ return 0;
+}
+
+int
+spc_misc_at_begin_form (void)
+{
+ return spc_misc_at_begin_page();
+}
+
+int
+spc_misc_at_end_form (void)
+{
+ return spc_misc_at_begin_page();
+}
+
static int
spc_handler_postscriptbox (struct spc_env *spe, struct spc_arg *ap)
{
@@ -130,12 +466,14 @@ spc_handler_null (struct spc_env *spe, struct spc_arg *args)
}
static struct spc_handler misc_handlers[] = {
- {"postscriptbox", spc_handler_postscriptbox},
- {"landscape", spc_handler_null}, /* handled at bop */
- {"papersize", spc_handler_null}, /* handled at bop */
- {"src:", spc_handler_null}, /* simply ignore */
- {"pos:", spc_handler_null}, /* simply ignore */
- {"om:", spc_handler_null} /* simply ignore */
+ {"postscriptbox", spc_handler_postscriptbox},
+ {"pdfcolorstackinit", spc_handler_pdfcolorstackinit},
+ {"pdfcolorstack", spc_handler_pdfcolorstack},
+ {"landscape", spc_handler_null}, /* handled at bop */
+ {"papersize", spc_handler_null}, /* handled at bop */
+ {"src:", spc_handler_null}, /* simply ignore */
+ {"pos:", spc_handler_null}, /* simply ignore */
+ {"om:", spc_handler_null} /* simply ignore */
};
@@ -143,18 +481,16 @@ int
spc_misc_check_special (const char *buffer, int size)
{
const char *p, *endptr;
- int i;
+ int i;
p = buffer;
endptr = p + size;
skip_white(&p, endptr);
- size = (int) (endptr - p);
- for (i = 0;
- i < sizeof(misc_handlers)/sizeof(struct spc_handler); i++) {
+ size = (int) (endptr - p);
+ for (i = 0; i < sizeof(misc_handlers)/sizeof(struct spc_handler); i++) {
if (size >= strlen(misc_handlers[i].key) &&
- !strncmp(p, misc_handlers[i].key,
- strlen(misc_handlers[i].key))) {
+ !strncmp(p, misc_handlers[i].key, strlen(misc_handlers[i].key))) {
return 1;
}
}
@@ -163,19 +499,17 @@ spc_misc_check_special (const char *buffer, int size)
}
int
-spc_misc_setup_handler (struct spc_handler *handle,
- struct spc_env *spe, struct spc_arg *args)
+spc_misc_setup_handler (struct spc_handler *handle, struct spc_env *spe, struct spc_arg *args)
{
const char *key;
- int i, keylen;
+ int i, keylen;
ASSERT(handle && spe && args);
skip_white(&args->curptr, args->endptr);
key = args->curptr;
- while (args->curptr < args->endptr &&
- isalpha((unsigned char)args->curptr[0])) {
+ while (args->curptr < args->endptr && isalpha((unsigned char)args->curptr[0])) {
args->curptr++;
}
@@ -189,10 +523,9 @@ spc_misc_setup_handler (struct spc_handler *handle,
return -1;
}
- for (i = 0;
- i < sizeof(misc_handlers)/sizeof(struct spc_handler); i++) {
+ for (i = 0; i < sizeof(misc_handlers)/sizeof(struct spc_handler); i++) {
if (keylen == strlen(misc_handlers[i].key) &&
- !strncmp(key, misc_handlers[i].key, keylen)) {
+ !strncmp(key, misc_handlers[i].key, keylen)) {
skip_white(&args->curptr, args->endptr);
diff --git a/Build/source/texk/dvipdfm-x/spc_misc.h b/Build/source/texk/dvipdfm-x/spc_misc.h
index 1dce3582cd0..413c5d88ccc 100644
--- a/Build/source/texk/dvipdfm-x/spc_misc.h
+++ b/Build/source/texk/dvipdfm-x/spc_misc.h
@@ -26,7 +26,11 @@
#include "specials.h"
extern int spc_misc_check_special (const char *buffer, int size);
-extern int spc_misc_setup_handler (struct spc_handler *handle,
- struct spc_env *spe, struct spc_arg *args);
+extern int spc_misc_setup_handler (struct spc_handler *handle, struct spc_env *spe, struct spc_arg *args);
+extern int spc_misc_at_begin_document (void);
+extern int spc_misc_at_end_document (void);
+extern int spc_misc_at_begin_page (void);
+extern int spc_misc_at_begin_form (void);
+extern int spc_misc_at_end_form (void);
#endif /* _SPC_MISC_H_ */
diff --git a/Build/source/texk/dvipdfm-x/spc_pdfm.c b/Build/source/texk/dvipdfm-x/spc_pdfm.c
index fbe57618f08..50310b707e7 100644
--- a/Build/source/texk/dvipdfm-x/spc_pdfm.c
+++ b/Build/source/texk/dvipdfm-x/spc_pdfm.c
@@ -891,23 +891,38 @@ spc_handler_pdfm_xann (struct spc_env *spe, struct spc_arg *args)
static int
spc_handler_pdfm_bcolor (struct spc_env *spe, struct spc_arg *ap)
{
- int error;
- pdf_color fc, sc;
+ int error = 0;
+ pdf_color fc, sc;
pdf_color *pfc, *psc;
pdf_color_get_current(&psc, &pfc);
- error = spc_util_read_pdfcolor(spe, &fc, ap, pfc);
- if (!error) {
- if (ap->curptr < ap->endptr) {
- error = spc_util_read_pdfcolor(spe, &sc, ap, psc);
- } else {
- pdf_color_copycolor(&sc, &fc);
+ if (ap->curptr <= ap->endptr + strlen("fill") &&
+ !memcmp(ap->curptr, "fill", strlen("fill"))) {
+ ap->curptr += strlen("fill");
+ skip_white(&ap->curptr, ap->endptr);
+ error = spc_util_read_pdfcolor(spe, &fc, ap, pfc);
+ pdf_color_copycolor(&sc, psc);
+ } else if (ap->curptr <= ap->endptr + strlen("stroke") &&
+ !memcmp(ap->curptr, "stroke", strlen("stroke"))) {
+ ap->curptr += strlen("stroke");
+ skip_white(&ap->curptr, ap->endptr);
+ error = spc_util_read_pdfcolor(spe, &sc, ap, psc);
+ pdf_color_copycolor(&fc, pfc);
+ } else {
+ error = spc_util_read_pdfcolor(spe, &fc, ap, pfc);
+ if (!error) {
+ if (ap->curptr < ap->endptr) {
+ error = spc_util_read_pdfcolor(spe, &sc, ap, psc);
+ } else {
+ pdf_color_copycolor(&sc, &fc);
+ }
}
}
- if (error)
+ if (error) {
spc_warn(spe, "Invalid color specification?");
- else {
+ } else {
+ skip_white(&ap->curptr, ap->endptr);
pdf_color_push(&sc, &fc); /* save currentcolor */
}
@@ -921,24 +936,39 @@ spc_handler_pdfm_bcolor (struct spc_env *spe, struct spc_arg *ap)
static int
spc_handler_pdfm_scolor (struct spc_env *spe, struct spc_arg *ap)
{
- int error;
- pdf_color fc, sc;
+ int error = 0;
+ pdf_color fc, sc;
pdf_color *pfc, *psc;
pdf_color_get_current(&psc, &pfc);
- error = spc_util_read_pdfcolor(spe, &fc, ap, pfc);
- if (!error) {
- if (ap->curptr < ap->endptr) {
- error = spc_util_read_pdfcolor(spe, &sc, ap, psc);
- } else {
- pdf_color_copycolor(&sc, &fc);
+ if (ap->curptr <= ap->endptr + strlen("fill") &&
+ !memcmp(ap->curptr, "fill", strlen("fill"))) {
+ ap->curptr += strlen("fill");
+ skip_white(&ap->curptr, ap->endptr);
+ error = spc_util_read_pdfcolor(spe, &fc, ap, pfc);
+ pdf_color_copycolor(&sc, psc);
+ } else if (ap->curptr <= ap->endptr + strlen("stroke") &&
+ !memcmp(ap->curptr, "stroke", strlen("stroke"))) {
+ ap->curptr += strlen("stroke");
+ skip_white(&ap->curptr, ap->endptr);
+ error = spc_util_read_pdfcolor(spe, &sc, ap, psc);
+ pdf_color_copycolor(&fc, pfc);
+ } else {
+ error = spc_util_read_pdfcolor(spe, &fc, ap, pfc);
+ if (!error) {
+ if (ap->curptr < ap->endptr) {
+ error = spc_util_read_pdfcolor(spe, &sc, ap, psc);
+ } else {
+ pdf_color_copycolor(&sc, &fc);
+ }
}
}
- if (error)
+ if (error) {
spc_warn(spe, "Invalid color specification?");
- else
+ } else {
pdf_color_set(&sc, &fc);
+ }
return error;
}
@@ -1736,7 +1766,7 @@ spc_handler_pdfm_fstream (struct spc_env *spe, struct spc_arg *args)
static int
spc_handler_pdfm_bform (struct spc_env *spe, struct spc_arg *args)
{
- int xobj_id;
+ int error;
char *ident;
pdf_rect cropbox;
pdf_coord cp;
@@ -1786,16 +1816,14 @@ spc_handler_pdfm_bform (struct spc_env *spe, struct spc_arg *args)
}
spc_get_current_point(spe, &cp);
- xobj_id = pdf_doc_begin_grabbing(ident, cp.x, cp.y, &cropbox);
+ error = spc_begin_form(spe, ident, cp, &cropbox);
- if (xobj_id < 0) {
- RELEASE(ident);
+ if (error)
spc_warn(spe, "Couldn't start form object.");
- return -1;
- }
+
RELEASE(ident);
- return 0;
+ return error;
}
/* An extra dictionary after exobj must be merged to the form dictionary,
@@ -1805,6 +1833,7 @@ spc_handler_pdfm_bform (struct spc_env *spe, struct spc_arg *args)
static int
spc_handler_pdfm_eform (struct spc_env *spe, struct spc_arg *args)
{
+ int error;
pdf_obj *attrib = NULL;
struct spc_pdf_ *sd = &_pdf_stat;
@@ -1821,9 +1850,9 @@ spc_handler_pdfm_eform (struct spc_env *spe, struct spc_arg *args)
if (sd->pageresources) {
pdf_foreach_dict(sd->pageresources, forallresourcecategory, NULL);
}
- pdf_doc_end_grabbing(attrib);
+ error = spc_end_form(spe, attrib);
- return 0;
+ return error;
}
/* Saved XObjects can be used as follows:
diff --git a/Build/source/texk/dvipdfm-x/specials.c b/Build/source/texk/dvipdfm-x/specials.c
index 0b51e5eb350..1b73b35be72 100644
--- a/Build/source/texk/dvipdfm-x/specials.c
+++ b/Build/source/texk/dvipdfm-x/specials.c
@@ -528,6 +528,8 @@ static struct {
int (*eodhk_func) (void);
int (*bophk_func) (void);
int (*eophk_func) (void);
+ int (*bofhk_func) (void);
+ int (*eofhk_func) (void);
int (*check_func) (const char *, int);
int (*setup_func) (struct spc_handler *, struct spc_env *, struct spc_arg *);
} known_specials[] = {
@@ -537,6 +539,8 @@ static struct {
spc_pdfm_at_end_document,
NULL,
spc_pdfm_at_end_page,
+ NULL,
+ NULL,
spc_pdfm_check_special,
spc_pdfm_setup_handler
},
@@ -546,6 +550,8 @@ static struct {
NULL,
NULL,
NULL,
+ NULL,
+ NULL,
spc_xtx_check_special,
spc_xtx_setup_handler
},
@@ -555,6 +561,8 @@ static struct {
NULL,
NULL,
NULL,
+ NULL,
+ NULL,
spc_dvipdfmx_check_special,
spc_dvipdfmx_setup_handler
},
@@ -564,6 +572,8 @@ static struct {
spc_dvips_at_end_document,
spc_dvips_at_begin_page,
spc_dvips_at_end_page,
+ NULL,
+ NULL,
spc_dvips_check_special,
spc_dvips_setup_handler
},
@@ -573,6 +583,8 @@ static struct {
NULL,
NULL,
NULL,
+ NULL,
+ NULL,
spc_color_check_special,
spc_color_setup_handler
},
@@ -582,6 +594,8 @@ static struct {
spc_tpic_at_end_document,
spc_tpic_at_begin_page,
spc_tpic_at_end_page,
+ NULL,
+ NULL,
spc_tpic_check_special,
spc_tpic_setup_handler
},
@@ -591,15 +605,19 @@ static struct {
spc_html_at_end_document,
spc_html_at_begin_page,
spc_html_at_end_page,
+ NULL,
+ NULL,
spc_html_check_special,
spc_html_setup_handler
},
- {"unknown",
- NULL,
- NULL,
- NULL,
+ {"compat",
+ spc_misc_at_begin_document,
+ spc_misc_at_end_document,
+ spc_misc_at_begin_page,
NULL,
+ spc_misc_at_begin_form,
+ spc_misc_at_end_form,
spc_misc_check_special,
spc_misc_setup_handler
},
@@ -608,6 +626,44 @@ static struct {
};
int
+spc_begin_form (struct spc_env *spe, const char *ident, pdf_coord cp, pdf_rect *cropbox)
+{
+ int error = 0;
+ int i, xobj_id;
+
+ xobj_id = pdf_doc_begin_grabbing(ident, cp.x, cp.y, cropbox);
+
+ if (xobj_id < 0) {
+ error = -1;
+ } else {
+ for (i = 0; known_specials[i].key != NULL; i++) {
+ if (known_specials[i].bofhk_func) {
+ error = known_specials[i].bofhk_func();
+ }
+ }
+ }
+
+ return error;
+}
+
+int
+spc_end_form (struct spc_env *spe, pdf_obj *attr)
+{
+ int error = 0;
+ int i;
+
+ pdf_doc_end_grabbing(attr);
+
+ for (i = 0; known_specials[i].key != NULL; i++) {
+ if (known_specials[i].eofhk_func) {
+ error = known_specials[i].eofhk_func();
+ }
+ }
+
+ return error;
+}
+
+int
spc_exec_at_begin_page (void)
{
int error = 0;
diff --git a/Build/source/texk/dvipdfm-x/specials.h b/Build/source/texk/dvipdfm-x/specials.h
index e9e61229127..17ced222335 100644
--- a/Build/source/texk/dvipdfm-x/specials.h
+++ b/Build/source/texk/dvipdfm-x/specials.h
@@ -63,6 +63,9 @@ extern int spc_end_annot (struct spc_env *spe);
extern int spc_resume_annot (struct spc_env *spe);
extern int spc_suspend_annot (struct spc_env *spe);
+extern int spc_begin_form (struct spc_env *spe, const char *ident, pdf_coord cp, pdf_rect *cropbox);
+extern int spc_end_form (struct spc_env *spe, pdf_obj *attr);
+
extern int spc_is_tracking_boxes (struct spc_env *spe);
/* linkmode 0: normal, 1: capture phantom texts */