Skip to content

faulty colors with pgf #10

@u-fischer

Description

@u-fischer

colorspace sets here both pgf colors to a spot color:

\def\pgfsys@color@&spot#1{%
  \pgfsys@color@&spot@stroke{#1}%
  \pgfsys@color@&spot@fill{#1}}

But actually pgf doesn't always set both colors and if colorspace tries to handle a non-spot color as spot color you get illegal 0 CS 1 SC 0 cs 1 sc in pdf and so a broken pdf. I suggest that colorspace does at least a light weight test here:


\RequirePackage{expl3}
\ExplSyntaxOn
\pdf_uncompress:
\ExplSyntaxOff
\documentclass{article}
\usepackage{tikz,colorspace}
\ExplSyntaxOn\makeatletter
%if the color is not a spot color, color space shouldn't set it.
%this is a simple test looking if the specification starts with a /:
\cs_set:cpn {pgfsys@color@&spot@fill} #1{%
  \spc@getir{\string\color@pgffillcolor}%
  \tl_if_head_eq_charcode:fNTF {\spc@ir}/
  {
    \pgfsysprotocol@literal{\spc@ir\space cs}%
    \pgfsysprotocol@literal{#1~sc}
  }
  {
    \PackageWarning{colorspace}{color@pgffillcolor~is~not~a~spot~color,~ignored}{}
  }}
  
\cs_set:cpn {pgfsys@color@&spot@stroke} #1{%
  \spc@getir{\string\color@pgfstrokecolor}%
  \tl_if_head_eq_charcode:fNTF {\spc@ir}/
   {
     \pgfsysprotocol@literal{\spc@ir\space CS}%
     \pgfsysprotocol@literal{#1~SC}
   }
   {
    \PackageWarning{colorspace}{color@pgffillcolor~is~not~a~spot~color,~ignored}{}
   }}
\ExplSyntaxOff\makeatother

\definespotcolor{myblue}{HKS 44 K}[cmyk]{1,0.5,0,0}


\begin{document}
\tikz\node[text=myblue]{abc};
\end{document}

The warning is optional but helps to debug the places. In the example it has two hits:

Package colorspace Warning: color@pgffillcolor is not a spot color, ignored on 
input line 72.


Package colorspace Warning: color@pgffillcolor is not a spot color, ignored on 
input line 72.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions