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

SVG アニメーション(単一ファイル出力)でカラーコードに svg 要素の id が混入して色が正しく表示されなくなる #16

Open
tagacchy opened this issue Jan 17, 2023 · 2 comments

Comments

@tagacchy
Copy link

はじめまして。

Windows 版 TeX2img で SVG アニメーションを作成しようとした際に標記の不具合に遭遇したのでご連絡いたしました。

環境:

  • Windows 11 22H2
  • LuaLaTeX (TeX Live 2022)
  • TeX2img 2.2.1
  • MuPDF 1.21.0

この不具合は以下の example.tex で発生します。

%% example.tex
\documentclass[tikz]{standalone}

\usepackage{tikz}

\begin{document}

% 1st page
\tikz \node[circle, fill = red] {};

% 2nd page
\tikz \node[circle, fill = blue] {};

\end{document}

このファイルを TeX2img で読み込み、「単一ファイルで出力」の設定のもとで SVG を生成すると、以下のように fill 属性の値のカラーコードに svg 要素の id が混入し、色を正しく表示できなくなります(カラーコードを手直しすれば正しく表示されます)。

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" xmlns="http://www.w3.org/2000/svg">
  <defs>
    <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="9.4pt" height="9.4pt" viewBox="0 0 9.4 9.4" id="5sqwinyz-1">
      <path transform="matrix(.00359712,0,0,-.00359712,0,9.4)" d="M2611.06 1305.49C2611.06 2026.54 2026.54 2611.06 1305.49 2611.06 584.434 2611.06-.0820313 2026.54-.0820313 1305.49-.0820313 584.434 584.434-.0820313 1305.49-.0820313 2026.54-.0820313 2611.06 584.434 2611.06 1305.49ZM1305.49 1305.49" fill="#5sqwinyz-1-ff0000" />
    </svg>
    <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="9.4pt" height="9.4pt" viewBox="0 0 9.4 9.4" id="5sqwinyz-2">
      <path transform="matrix(.00359712,0,0,-.00359712,0,9.4)" d="M2611.06 1305.49C2611.06 2026.54 2026.54 2611.06 1305.49 2611.06 584.434 2611.06-.0820313 2026.54-.0820313 1305.49-.0820313 584.434 584.434-.0820313 1305.49-.0820313 2026.54-.0820313 2611.06 584.434 2611.06 1305.49ZM1305.49 1305.49" fill="#5sqwinyz-2-0000ff" />
    </svg>
  </defs>
  <use>
    <animate attributeName="xlink:href" begin="0s" dur="2s" repeatCount="indefinite" values="#5sqwinyz-1;#5sqwinyz-2" />
  </use>
</svg>

「単一ファイルで出力」の設定を除外した場合は問題は生じません。

  • example-1.svg
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="9.396pt" height="9.396pt" viewBox="0 0 9.396 9.396">
<defs>
<clipPath id="clip_1">
<path transform="matrix(1,0,0,-1,0,9.396)" d="M0 0H9.393V9.393H0Z"/>
</clipPath>
</defs>
<g clip-path="url(#clip_1)">
<path transform="matrix(1,0,0,-1,4.696,4.7)" d="M4.6963 0C4.6963 2.59372 2.59372 4.6963 0 4.6963-2.59372 4.6963-4.6963 2.59372-4.6963 0-4.6963-2.59372-2.59372-4.6963 0-4.6963 2.59372-4.6963 4.6963-2.59372 4.6963 0ZM0 0" fill="#ff0000"/>
</g>
</svg>
  • example-2.svg
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="9.396pt" height="9.396pt" viewBox="0 0 9.396 9.396">
<defs>
<clipPath id="clip_1">
<path transform="matrix(1,0,0,-1,0,9.396)" d="M0 0H9.393V9.393H0Z"/>
</clipPath>
</defs>
<g clip-path="url(#clip_1)">
<path transform="matrix(1,0,0,-1,4.696,4.7)" d="M4.6963 0C4.6963 2.59372 2.59372 4.6963 0 4.6963-2.59372 4.6963-4.6963 2.59372-4.6963 0-4.6963-2.59372-2.59372-4.6963 0-4.6963 2.59372-4.6963 4.6963-2.59372 4.6963 0ZM0 0" fill="#0000ff"/>
</g>
</svg>

おそらくファイル結合時の処理に何らかの問題があると思われますので、ご確認いただければと思います。

不具合発生時のログは以下の通りです。

C:\example>"C:\texlive\2022\bin\win32\lualatex.exe" -interaction=nonstopmode hb40domh.tex
This is LuaHBTeX, Version 1.15.0 (TeX Live 2022) 
 restricted system commands enabled.
(./hb40domh.tex
LaTeX2e <2022-11-01> patch level 1
 L3 programming layer <2022-12-17>
(c:/texlive/2022/texmf-dist/tex/latex/standalone/standalone.cls
Document Class: standalone 2022/10/10 v1.3b Class to compile TeX sub-files stan
dalone
(c:/texlive/2022/texmf-dist/tex/latex/tools/shellesc.sty)
(c:/texlive/2022/texmf-dist/tex/generic/iftex/ifluatex.sty
(c:/texlive/2022/texmf-dist/tex/generic/iftex/iftex.sty))
(c:/texlive/2022/texmf-dist/tex/latex/xkeyval/xkeyval.sty
(c:/texlive/2022/texmf-dist/tex/generic/xkeyval/xkeyval.tex
(c:/texlive/2022/texmf-dist/tex/generic/xkeyval/xkvutils.tex
(c:/texlive/2022/texmf-dist/tex/generic/xkeyval/keyval.tex))))
(c:/texlive/2022/texmf-dist/tex/latex/standalone/standalone.cfg)
(c:/texlive/2022/texmf-dist/tex/latex/base/article.cls
Document Class: article 2022/07/02 v1.4n Standard LaTeX document class
(c:/texlive/2022/texmf-dist/tex/latex/base/size10.clo))
(c:/texlive/2022/texmf-dist/tex/generic/luatex85/luatex85.sty)
(c:/texlive/2022/texmf-dist/tex/generic/pdftexcmds/pdftexcmds.sty
(c:/texlive/2022/texmf-dist/tex/generic/infwarerr/infwarerr.sty)
(c:/texlive/2022/texmf-dist/tex/generic/ltxcmds/ltxcmds.sty))
(c:/texlive/2022/texmf-dist/tex/latex/pgf/frontendlayer/tikz.sty
(c:/texlive/2022/texmf-dist/tex/latex/pgf/basiclayer/pgf.sty
(c:/texlive/2022/texmf-dist/tex/latex/pgf/utilities/pgfrcs.sty
(c:/texlive/2022/texmf-dist/tex/generic/pgf/utilities/pgfutil-common.tex
(c:/texlive/2022/texmf-dist/tex/generic/pgf/utilities/pgfutil-common-lists.tex)
) (c:/texlive/2022/texmf-dist/tex/generic/pgf/utilities/pgfutil-latex.def)
(c:/texlive/2022/texmf-dist/tex/generic/pgf/utilities/pgfrcs.code.tex
(c:/texlive/2022/texmf-dist/tex/generic/pgf/pgf.revision.tex)))
(c:/texlive/2022/texmf-dist/tex/latex/pgf/basiclayer/pgfcore.sty
(c:/texlive/2022/texmf-dist/tex/latex/graphics/graphicx.sty
(c:/texlive/2022/texmf-dist/tex/latex/graphics/graphics.sty
(c:/texlive/2022/texmf-dist/tex/latex/graphics/trig.sty)
(c:/texlive/2022/texmf-dist/tex/latex/graphics-cfg/graphics.cfg)
(c:/texlive/2022/texmf-dist/tex/latex/graphics-def/luatex.def)))
(c:/texlive/2022/texmf-dist/tex/latex/pgf/systemlayer/pgfsys.sty
(c:/texlive/2022/texmf-dist/tex/generic/pgf/systemlayer/pgfsys.code.tex
(c:/texlive/2022/texmf-dist/tex/generic/pgf/utilities/pgfkeys.code.tex
(c:/texlive/2022/texmf-dist/tex/generic/pgf/utilities/pgfkeysfiltered.code.tex)
) (c:/texlive/2022/texmf-dist/tex/generic/pgf/systemlayer/pgf.cfg)
(c:/texlive/2022/texmf-dist/tex/generic/pgf/systemlayer/pgfsys-luatex.def
(c:/texlive/2022/texmf-dist/tex/generic/pgf/systemlayer/pgfsys-common-pdf.def))
)
(c:/texlive/2022/texmf-dist/tex/generic/pgf/systemlayer/pgfsyssoftpath.code.tex
)
(c:/texlive/2022/texmf-dist/tex/generic/pgf/systemlayer/pgfsysprotocol.code.tex
)) (c:/texlive/2022/texmf-dist/tex/latex/xcolor/xcolor.sty
(c:/texlive/2022/texmf-dist/tex/latex/graphics-cfg/color.cfg)
(c:/texlive/2022/texmf-dist/tex/latex/graphics/mathcolor.ltx))
(c:/texlive/2022/texmf-dist/tex/generic/pgf/basiclayer/pgfcore.code.tex
(c:/texlive/2022/texmf-dist/tex/generic/pgf/math/pgfmath.code.tex
(c:/texlive/2022/texmf-dist/tex/generic/pgf/math/pgfmathcalc.code.tex
(c:/texlive/2022/texmf-dist/tex/generic/pgf/math/pgfmathutil.code.tex)
(c:/texlive/2022/texmf-dist/tex/generic/pgf/math/pgfmathparser.code.tex)
(c:/texlive/2022/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.code.tex
(c:/texlive/2022/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.basic.code.te
x)
(c:/texlive/2022/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.trigonometric
.code.tex)
(c:/texlive/2022/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.random.code.t
ex)
(c:/texlive/2022/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.comparison.co
de.tex)
(c:/texlive/2022/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.base.code.tex
)
(c:/texlive/2022/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.round.code.te
x)
(c:/texlive/2022/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.misc.code.tex
)
(c:/texlive/2022/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.integerarithm
etics.code.tex)))
(c:/texlive/2022/texmf-dist/tex/generic/pgf/math/pgfmathfloat.code.tex))
(c:/texlive/2022/texmf-dist/tex/generic/pgf/math/pgfint.code.tex)
(c:/texlive/2022/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepoints.code.tex)
(c:/texlive/2022/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepathconstruct.cod
e.tex)
(c:/texlive/2022/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepathusage.code.te
x)
(c:/texlive/2022/texmf-dist/tex/generic/pgf/basiclayer/pgfcorescopes.code.tex)
(c:/texlive/2022/texmf-dist/tex/generic/pgf/basiclayer/pgfcoregraphicstate.code
.tex)
(c:/texlive/2022/texmf-dist/tex/generic/pgf/basiclayer/pgfcoretransformations.c
ode.tex)
(c:/texlive/2022/texmf-dist/tex/generic/pgf/basiclayer/pgfcorequick.code.tex)
(c:/texlive/2022/texmf-dist/tex/generic/pgf/basiclayer/pgfcoreobjects.code.tex)

(c:/texlive/2022/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepathprocessing.co
de.tex)
(c:/texlive/2022/texmf-dist/tex/generic/pgf/basiclayer/pgfcorearrows.code.tex)
(c:/texlive/2022/texmf-dist/tex/generic/pgf/basiclayer/pgfcoreshade.code.tex)
(c:/texlive/2022/texmf-dist/tex/generic/pgf/basiclayer/pgfcoreimage.code.tex
(c:/texlive/2022/texmf-dist/tex/generic/pgf/basiclayer/pgfcoreexternal.code.tex
))
(c:/texlive/2022/texmf-dist/tex/generic/pgf/basiclayer/pgfcorelayers.code.tex)
(c:/texlive/2022/texmf-dist/tex/generic/pgf/basiclayer/pgfcoretransparency.code
.tex)
(c:/texlive/2022/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepatterns.code.tex
) (c:/texlive/2022/texmf-dist/tex/generic/pgf/basiclayer/pgfcorerdf.code.tex)))
 (c:/texlive/2022/texmf-dist/tex/generic/pgf/modules/pgfmoduleshapes.code.tex)
(c:/texlive/2022/texmf-dist/tex/generic/pgf/modules/pgfmoduleplot.code.tex)
(c:/texlive/2022/texmf-dist/tex/latex/pgf/compatibility/pgfcomp-version-0-65.st
y)
(c:/texlive/2022/texmf-dist/tex/latex/pgf/compatibility/pgfcomp-version-1-18.st
y)) (c:/texlive/2022/texmf-dist/tex/latex/pgf/utilities/pgffor.sty
(c:/texlive/2022/texmf-dist/tex/latex/pgf/utilities/pgfkeys.sty
(c:/texlive/2022/texmf-dist/tex/generic/pgf/utilities/pgfkeys.code.tex))
(c:/texlive/2022/texmf-dist/tex/latex/pgf/math/pgfmath.sty
(c:/texlive/2022/texmf-dist/tex/generic/pgf/math/pgfmath.code.tex))
(c:/texlive/2022/texmf-dist/tex/generic/pgf/utilities/pgffor.code.tex
(c:/texlive/2022/texmf-dist/tex/generic/pgf/math/pgfmath.code.tex)))
(c:/texlive/2022/texmf-dist/tex/generic/pgf/frontendlayer/tikz/tikz.code.tex
(c:/texlive/2022/texmf-dist/tex/generic/pgf/libraries/pgflibraryplothandlers.co
de.tex)
(c:/texlive/2022/texmf-dist/tex/generic/pgf/modules/pgfmodulematrix.code.tex)
(c:/texlive/2022/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzli
brarytopaths.code.tex))))
(c:/texlive/2022/texmf-dist/tex/latex/l3backend/l3backend-luatex.def)
No file hb40domh.aux.
(c:/texlive/2022/texmf-dist/tex/latex/base/ts1cmr.fd)
(c:/texlive/2022/texmf-dist/tex/context/base/mkii/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
) (c:/texlive/2022/texmf-dist/tex/latex/epstopdf-pkg/epstopdf-base.sty
(c:/texlive/2022/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg)) [1]
[2] (./hb40domh.aux))
 413 words of node memory still in use:
   3 hlist, 1 vlist, 1 rule, 2 glue, 3 kern, 1 glyph, 5 attribute, 48 glue_spec
, 5 attribute_list, 2 write nodes
   avail lists: 2:114,3:90,4:22,5:22,6:2,7:65,9:60
Output written on hb40domh.pdf (2 pages, 1350 bytes).
Transcript written on hb40domh.log.

C:\example>"C:\texlive\2022\bin\win32\pdftex.exe"  -no-shell-escape -interaction=nonstopmode "uelx0q2x.tex"
This is pdfTeX, Version 3.141592653-2.6-1.40.24 (TeX Live 2022) (preloaded format=pdftex)
entering extended mode
(./uelx0q2x.tex 
Pages: 2
 )
No pages of output.
Transcript written on uelx0q2x.log.

C:\example>"C:\texlive\2022\bin\win32\rungs.exe" -q -dBATCH -dNOPAUSE -sDEVICE=bbox -c "<< /WhiteIsOpaque true >> setpagedevice" -dFirstPage=1 -dLastPage=2 "hb40domh.pdf"
%%BoundingBox: 0 0 10 10
%%HiResBoundingBox: 0.000000 0.000000 9.396000 9.396000
%%BoundingBox: 0 0 10 10
%%HiResBoundingBox: 0.000000 0.000000 9.396000 9.396000


C:\example>"C:\texlive\2022\bin\win32\pdftex.exe"  -no-shell-escape -interaction=nonstopmode "jhdzve0i.tex"
This is pdfTeX, Version 3.141592653-2.6-1.40.24 (TeX Live 2022) (preloaded format=pdftex)
entering extended mode
(./jhdzve0i.tex [1 <./hb40domh.pdf>] [1 <./hb40domh.pdf>] )
Output written on jhdzve0i.pdf (2 pages, 2175 bytes).
Transcript written on jhdzve0i.log.

C:\example>"C:\texlive\2022\bin\win32\rungs.exe" -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dAutoRotatePages=/None -dCompatibilityLevel=1.5 -r20016 -dNoOutputFonts -sOutputFile="5sqwinyz.pdf" -c"" -f "vkowzktv.pdf"
GPL Ghostscript 9.56.1 (2022-04-04)
Copyright (C) 2022 Artifex Software, Inc.  All rights reserved.
This software is supplied under the GNU AGPLv3 and comes with NO WARRANTY:
see the file COPYING for details.
Processing pages 1 through 2.
Page 1
Page 2

C:\example>"C:\texlive\TeX2img\mutool.exe" draw -o "5sqwinyz-%d.svg" "5sqwinyz.pdf" 1,2
page 5sqwinyz.pdf 1
page 5sqwinyz.pdf 2

TeX2img: Making animation svg... done

以上、よろしくお願いいたします。

@abenori
Copy link
Owner

abenori commented Aug 18, 2023

すっかり放置していてすみません.どうしたものかなぁと思っていたのですが,単純に後ろに[0-9a-f]が3つまたは9つの場合にはidを追加しないようしてみました(つもり)

https://www.ms.u-tokyo.ac.jp/~abenori/soft/bin/TeX2img_2.2.1_20230818.zip

こちらではそもそももともとのファイルでfill="rgb(255,0,0)"のように変換されているようで,そのままでもうまく言ってしまうためこの変更でよくなるかは確認できていません.

@tagacchy
Copy link
Author

お返事が遅くなりすみません。試してみましたが、依然として同様の不具合が生じています。
https://www.ms.u-tokyo.ac.jp/~abenori/soft/index.html の改変版mutoolも試しましたが解消されませんでした。

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

No branches or pull requests

2 participants