[XeTeX] spotcolor package
Apostolos Syropoulos
asyropoulos at yahoo.com
Wed Jul 16 21:37:37 CEST 2014
Hello,
A few days ago someone asked me to see whether it is possible to use spot colors
in XeLaTeX.Let me say that until that moment I had no idea what spot colors are...
Now, after some search I found the spotcolor package, which of course works only
with pdfLaTeX. I tried to transform the package so to make it work with XeLaTeX.
It took my some time to understand how the original package works but in the end
I managed to create a package that works (the attached file was generated with
this package). However, one thing does not work: background color for pages.
I tried to see why it does not worked and I realized that there is a problem
with color definitions. In order to make things clear, here is how a cmyk color
is defined internally when using XeLaTeX
\def\color at cmyk#1#2{\c at lor@@cmyk#2\@@#1}
\def\c at lor@@cmyk#1,#2,#3,#4\@@#5{%
\c at lor@arg{#4}%
\c at lor@arg{#1}%
\c at lor@arg{#2}%
\c at lor@arg{#3}%
\edef#5{cmyk #1 #2 #3 #4}%
}
and here is how it is defined when using pdfLaTeX
\def\color at cmyk#1#2{\c at lor@@cmyk#2\@@#1}
\def\c at lor@@cmyk#1,#2,#3,#4\@@#5{%
\c at lor@arg{#4}%
\c at lor@arg{#1}%
\c at lor@arg{#2}%
\c at lor@arg{#3}%
\edef#5{#1 #2 #3 #4 k #1 #2 #3 #4 K}%
}
You will notice that in XeLaTeX one uses the word cmyk followed by the components
that make up this color. However, in pdfLaTeX, as expected (!), the driver uses
the k and K operators directly. Package spotcolor uses the following to define
spot colors:
\def\color at spotcolor#1#2{\c at lor@@spotcolor#2\@@#1}
\def\c at lor@@spotcolor#1,#2\@@#3{%
\c at lor@arg{#2}%
\edef#3{/#1 cs /#1 CS #2 sc #2 SC}%
}
Here it uses four PDF operators. Unfortunately, it is impossible (?) right now
to solve this problem when using XeLaTeX. I think the reason is that in file
spc_util.c of the dvipdfm-x source code there is the following function that
reads color specifications.
static int
spc_read_color_pdf (struct spc_env *spe, pdf_color *colorspec, struct spc_arg *ap)
{
..........................................................
nc = spc_util_read_numbers(cv, 4, spe, 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 */
.........................................................
}
.............................................................
return error;
}
As is obvious there is no provision for reading spot color specification and
therefore I get meaningless (?) messages like the following one:
** WARNING ** No valid color specified?
** WARNING ** Interpreting special command background (color) failed.
** WARNING ** >> at page="5" position="(72, 769.89)" (in PDF)
** WARNING ** >> xxx "background /SOMECOLOR cs /SOMECOLOR CS 1.0 sc 1.0 SC"
** WARNING ** >> Reading special command stopped around >>/SOMECOLOR cs /SOMECOLOR CS 1.0 sc 1.0 SC<<
** WARNING ** No valid color specified?
** WARNING ** Interpreting special command push (color) failed.
** WARNING ** >> at page="6" position="(148.712, 702.783)" (in PDF)
** WARNING ** >> xxx "color push /SOMECOLOR cs /SOMECOLOR CS 1.0 sc 1.0 SC"
** WARNING ** >> Reading special command stopped around >>/SOMECOLOR cs /SOMECOLOR CS 1.0 sc 1.0 SC<<
Since adding support for spot color seems to me very important, I think dvipdfm-x should patched.
But since I haven't studied how dvipdfm-x works, I am not sure how to proceed. Thus, I would
like to ask for ideas and/or advice.
Thank you,
A.S.
----------------------
Apostolos Syropoulos
Xanthi, Greece
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.pdf
Type: application/x-download
Size: 46590 bytes
Desc: not available
URL: <http://tug.org/pipermail/xetex/attachments/20140716/89494f35/attachment-0001.bin>
More information about the XeTeX
mailing list