Pergunta

I need to extend TeXtoGIF to be able to handle XeTeX, ConTeXt, and other more modern implementations of TeX (point being that they can handle multiple fonts). Unfortunately, XeTeX in particular does not support DVI as an output format for its input, and my modifications break.

Please see the diff of changes at GitHub. My changes to the codebase are as follows:

  • Introduce a variable $cmdTeX to hold the TeX engine (LaTeX, XeLaTeX, etc.)
  • Add the option -xetex (or anything beginning with an x, really) to specify xelatex as the engine
  • Substitute the hard-coded latex call with the variable $cmdTeX.

I see two options to fixing this issue:

  1. Coerce XeLaTeX to produce standard DVI output which, IIRC, isn't possible.
  2. Find another sequence of commands (probably a different use of GS, which is why I included the tag, but so be it) to work with PDF output directly instead of DVI

So, I guess the question boils down to:
How can I convert a PDF into GIF without using graphical software?
which, probably, isn't a good fit for SO anymore IMHO.

Foi útil?

Solução

It sounds like what you have is a patch you would like to submit to the author. Have you contacted him? Unfortunately his software doesn't (appear to) include a license so it may be hard to proceed from a legal standpoint. Most of the time in the open source world, if you encounter a non-responsive (or unwilling) author, you can do as you have already done, fork and patch. At that point you can choose to publish your new version, possibly with a new name, and conforming to the author's license.

From a software standpoint, the code is rather ancient, written for Perl 4. Because Perl has excellent backwards compatibility it will probably still work, but the question is, do you really want to? It may depend on your use-case. The original author was making gifs to use in web pages. If this is what you are doing, you might want to look at MathJaX which lets you use LaTeX right in your browser/HTML directly.

Outras dicas

Instead of adding to my Q, this turned out to be a valid solution to my overall issue and should be recorded as such.

I should also note that someone over at TeX.SX pointed me to the standalone class which provides an option convert which, using -shell-escape, can do just about everything I need. Thus,

\documentclass[convert={density=6000,
                           size=1920x1600,
                         outext=.png},
                border=1cm]{standalone}

\usepackage{fontspec}
\setmainfont{Zapfino}

\pagestyle{empty}

\begin{document}
it's all text
\end{document}

%%% Local Variables: 
%%% mode: latex
%%% TeX-engine: xetex
%%% TeX-master: t
%%% End: 

ConTeXt is not a modern TeX implementation (like LuaTeX, for instance). It's a macro package for several engines.

Since you want to support specific engines (e.g. XeTeX) and particular macro packages (e.g. ConTeXt), MathJax is not an option. You have to run the TeX engine, create a PDF and post process that PDF. I don't know why you choose GIF as a format, the vector format SVG would produce much prettier results, PNG would be my second choice.

Since you are not very specific about your input I assume you deal with multi page input files. You can use ghostscript to convert the PDF to a series of images.

As you said, you require GIF. According to gs -h ghostscript does not support GIF output, so we convert to PNG first:

gs                  \
  -sDEVICE=png256   \
  -dNOPAUSE         \
  -dBATCH           \
  -dSAFER           \
  -dTextAlphaBits=4 \
  -q                \
  -r300x300         \
  -sOutputFile=output-%02d.png input.pdf

Then use graphicsmagick or imagemagick to convert the PNGs to GIFs:

mogrify --format gif -- output-*.png
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top