Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support of CMYK colors in the dvisvgm backend #1319

Open
mgieseki opened this issue Apr 25, 2024 · 0 comments
Open

support of CMYK colors in the dvisvgm backend #1319

mgieseki opened this issue Apr 25, 2024 · 0 comments

Comments

@mgieseki
Copy link

Brief outline of the proposed feature

As of dvisvgm 3.3 the conversion of CMYK colors to RGB has been modified so that they are now more similar to those shown by Ghostscript and several PDF viewers. When using the dvips backend, the colors can be processed accordingly because the DVI file contains color specials. The dvisvgm backend, on the other hand, sometimes creates literal SVG fragments with the color hard-coded as RGB hex values. In this case, the CMYK to RGB conversion takes place in a LaTeX (or TikZ) package and dvisvgm can't apply its color interpolation.

Here's an example:

\documentclass[dvisvgm]{standalone}
\usepackage[cmyk]{xcolor}
\usepackage{tikz}
\definecolor{mycolor}{cmyk}{1, 0, 1, 0} 
\begin{document}
\begin{tikzpicture}
  \fill[mycolor] circle(2);
\end{tikzpicture}
\end{document}

The resulting SVG graphics created with dvips (left) and dvisvgm backend:

cmyktest-ps cmyktest

Here are the corresponding DVI snippets:

xxx: 'color push cmyk 1 0 1 0'
xxx: 'ps:: 56.69362 0.0 moveto '
xxx: 'ps:: 56.69362 31.31142 31.31142 56.69362 0.0 56.69362 curveto '
xxx: 'ps:: -31.31142 56.69362 -56.69362 31.31142 -56.69362 0.0 curveto '
xxx: 'ps:: -56.69362 -31.31142 -31.31142 -56.69362 0.0 -56.69362 curveto '
xxx: 'ps:: 31.31142 -56.69362 56.69362 -31.31142 56.69362 0.0 curveto '
xxx: 'ps:: closepath '
xxx: 'dvisvgm:raw <g stroke="#0f0" fill="#0f0">{?nl} '
xxx: 'dvisvgm:raw <path d=" '
xxx: 'dvisvgm:raw M 56.90549 0.0 C 56.90549 31.42844 31.42844 56.90549 0.0 56.90549 ... '
xxx: 'dvisvgm:raw " stroke="none"/>{?nl} '
xxx: 'dvisvgm:raw </g>{?nl} '

It would be great if the dvisvgm backend could create color specials too, e.g. something like this:

xxx: 'color push cmyk 1 0 1 0'
xxx: 'dvisvgm:raw <g stroke="{?color}" fill="{?color}">{?nl} '

To apply different stroke and fill colors, the SVG elements could also be split into several specials:

xxx: 'color push cmyk 1 0 1 0'
xxx: 'dvisvgm:raw <g stroke="{?color}"'
xxx: 'color pop'
xxx: 'color push cmyk 1 0 1 0'
xxx: 'dvisvgm:raw fill="{?color}">{?nl} '

Usage example

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

1 participant