Closed robertbachmann closed 1 year ago
The \transparent
macro used by the inkscape generated file is from transparent.sty
. http://mirrors.ctan.org/macros/latex/contrib/transparent/transparent.pdf
I takes a number from 0 -- 1, but careful 1 means 100% opaque:
- User interface The package transparent defines \transparent and \texttransparent. They are used like \color and \textcolor. The first argument is the transparency value between 0 and 1 where 0 is fully transparent and 1 is opaque.
I implemented it like this.
\_def\transparent#1{\_edef\_tmpt{\_expr[0]{(1-#1)*255}}\_transparency=\_tmpt}%
Not sure if there's an easy way to do it without the \_tmpt
Test case:
\fontfam[lm]
\OpTeX
\medskip
\inkinspic{figure2.pdf}
\bye
LaTeX test file I used:
\documentclass{article}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{transparent}
\begin{document}
\input{figure2.pdf_tex}
\end{document}
Second SVG file figure2.zip
Sceenshot of result:
You can use this code
\_def\transparent#1{\_ea\_transparency\_expanded{\_expr[0]{(1-.5)*255}} }
This is without \_tmpt
. If the \expr
macro was expandable in classical sense then simply \transparency=\expr...
would be enough. But it is not true in this case because \immediateassigment
is used in \expr
and this LuaTeX primitive is (wrongly) applied to the currently executed assignment \transparency=
not to the desired assignment inside the \expr
macro. I didn't know about this "feature" yet and I am not sure if it is feature or bug in LuaTeX.
Or we can use
\_def\transparent#1{\_transparency\_exprA[0]{(1-.5)*255} }
but we cannot be sure if the \_exprA
"API" will be stable in OpTeX. Maybe yes.
I did a more thorough investigation and I found that the issue is due to \afterassignment
used in the \trnasparency
macro. This primitive is applied to the first assignment done inside \expr
macro and not to the \_transpattr=
assignment. Now, I am sure this is feature, not bug.
Thanks for the explanation.
Commit: Extend
\_inkdefs
These macros may be generated by Inkscape's
latex-text-renderer.cpp
.Additional notes
The relevant code can be seen here https://gitlab.com/inkscape/inkscape/-/blob/master/src/extension/internal/latex-text-renderer.cpp#L390
Test case:
I'm using Inkscape 1.1.2 (0a00cf5339, 2022-02-04) with
inkscape figure.svg --export-type=pdf --export-latex -o figure.pdf
Inkscapes generates
I've attached the SVG file.
figure.zip