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

No output with radialshading in RTL context (lualatex) #934

Closed
seloumi opened this issue Oct 5, 2020 · 6 comments
Closed

No output with radialshading in RTL context (lualatex) #934

seloumi opened this issue Oct 5, 2020 · 6 comments
Milestone

Comments

@seloumi
Copy link

seloumi commented Oct 5, 2020

Brief outline of the bug

In RTL context (lualatex engine) radialshading do not produce result (example was taken from tikz manual)

Minimal working example (MWE)

% lualatex
\documentclass{article}
\usepackage{tikz}
\usepackage[bidi=basic,nil]{babel}
\babelprovide[import,main]{arabic}
            
\fboxsep=0pt            
\parindent=0pt
            
\begin{document}

% TRT

\fbox{%
\pgfdeclareradialshading{sphere}{\pgfpoint{0.5cm}{0.5cm}}%
{rgb(0cm)=(0.9,0,0);
rgb(0.7cm)=(0.7,0,0);
rgb(1cm)=(0.5,0,0);
rgb(1.05cm)=(1,1,1)}
\pgfuseshading{sphere}
}

\selectlanguage{nil}

% TLT

\fbox{%
\pgfdeclareradialshading{sphere}{\pgfpoint{0.5cm}{0.5cm}}%
{rgb(0cm)=(0.9,0,0);
rgb(0.7cm)=(0.7,0,0);
rgb(1cm)=(0.5,0,0);
rgb(1.05cm)=(1,1,1)}
\pgfuseshading{sphere}
}

\end{document}

image

@hmenke
Copy link
Member

hmenke commented Oct 5, 2020

Is this a regression or does this also happen with older versions of PGF (and older versions of LaTeX)?

@seloumi
Copy link
Author

seloumi commented Oct 5, 2020

I noticed the issue mid 2019, before that I don't know .

@muzimuzhi
Copy link
Member

muzimuzhi commented Oct 5, 2020

bidi option is added from babel v3.14, 2017/10/03 (see doc of babel v3.49, sec. 1.23 and relevant lines in changes-old.txt).

Quick tests show that both texlive 2019 and 2018 on Overleaf.com give the same, wrong output.

@seloumi
Copy link
Author

seloumi commented Oct 5, 2020

Remarque: if we add \bodydir TLT the result appears, but the position where to place \bodydir TLT differs if we use \pgfdeclareradialshading with optional argument or not.

% lualatex
% Notice position of \bodydir TLT with those two cases
\documentclass{article}
\usepackage{tikz}
\usepackage[bidi=basic,nil]{babel}
\babelprovide[import,main]{arabic}
            
\fboxsep=0pt            
\parindent=0pt
           
\begin{document}

% TRT

\makeatletter
\pgfutil@colorlet{tikz@ball}{red}
\pgfdeclareradialshading[tikz@ball]{ball}{\pgfqpoint{-10bp}{10bp}}{%
 color(0bp)=(tikz@ball!15!white);
 color(9bp)=(tikz@ball!75!white);
 color(18bp)=(tikz@ball!70!black);
 color(25bp)=(tikz@ball!50!black);
 color(50bp)=(black)}%
\makeatother 

{\bodydir TLT
\pgfuseshading{ball} 
}

{\bodydir TLT
\pgfdeclareradialshading{sphere}{\pgfpoint{-10bp}{10bp}}{%
color(0bp)=(red!15!white);
 color(9bp)=(red!75!white);
 color(18bp)=(red!70!black);
 color(25bp)=(red!50!black);
 color(50bp)=(black)}
}

\pgfuseshading{sphere} 

\end{document}

@seloumi
Copy link
Author

seloumi commented Oct 11, 2020

This work fine

% lualatex
\documentclass{article}
\usepackage{tikz}
\usepackage[bidi=basic,nil]{babel}
\babelprovide[import,main]{arabic}
                     
\makeatletter
\def\pgfsys@radialshading#1#2#3{%
  {%
    \pgf@parsefunc{#3}%
    \setbox\pgfutil@tempboxa=\hbox dir TLT to2\pgf@max{\vbox to2\pgf@max{\vfil\pgfsys@invoke{/Sh sh}}\hfil}%
    \pgf@process{#2}%
    \pgf@xa=\pgf@x%
    \pgf@ya=\pgf@y%
    \pgf@process{\pgfpoint{\pgf@max}{\pgf@max}}%
    \advance\pgf@xa by \pgf@x%
    \advance\pgf@ya by \pgf@y%
    \pgf@sys@bp@correct{\pgf@x}%
    \pgf@sys@bp@correct{\pgf@y}%
    \pgf@sys@bp@correct{\pgf@xa}%
    \pgf@sys@bp@correct{\pgf@ya}%
    \immediate\saveboxresource resources {%
      /Shading << /Sh << /ShadingType 3
      /ColorSpace \pgf@shading@device\space
      /Domain [\pgf@pdfparseddomain]
      /Coords [\pgf@sys@tonumber{\pgf@xa} \pgf@sys@tonumber{\pgf@ya} \pgf@doma\space \pgf@sys@tonumber{\pgf@x} \pgf@sys@tonumber{\pgf@y} \pgf@domb]
      /Function \pgf@pdfparsedfunction
      /Extend [true false] >> >>}\pgfutil@tempboxa% <<
    \xdef\pgfutil@tempa{\hbox{\noexpand\useboxresource\the\lastsavedboxresourceindex}}%
  }%
  \global\expandafter\let\csname @pgfshading#1!\endcsname=\pgfutil@tempa
}%
\makeatother
           
\begin{document}

% TRT

\makeatletter
\pgfutil@colorlet{tikz@ball}{red}
\pgfdeclareradialshading[tikz@ball]{ball}{\pgfqpoint{-10bp}{10bp}}{%
 color(0bp)=(tikz@ball!15!white);
 color(9bp)=(tikz@ball!75!white);
 color(18bp)=(tikz@ball!70!black);
 color(25bp)=(tikz@ball!50!black);
 color(50bp)=(black)}%
\makeatother 

\pgfuseshading{ball} 

\pgfdeclareradialshading{sphere}{\pgfpoint{-10bp}{10bp}}{%
color(0bp)=(red!15!white);
 color(9bp)=(red!75!white);
 color(18bp)=(red!70!black);
 color(25bp)=(red!50!black);
 color(50bp)=(black)}

\pgfuseshading{sphere} 

\end{document}

@hmenke
Copy link
Member

hmenke commented Oct 12, 2020

Thank you very much for finding a fix!

@hmenke hmenke closed this as completed Oct 12, 2020
@hmenke hmenke added this to the 3.1.7 milestone Nov 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants