# Given a PS interpreter, can pstricks be converted to pgf?

When producing pdf directly, PostScript code cannot be used, which means that pstricks macros do not work. Now, it is still possible to include pstricks code using external tools (running LaTeX on files built from the document's preamble and the figure's contents), but not as seamlessly as we could want.

My aim is to fix this, by implementing a PostScript interpreter in TeX. Before starting such a large project (the part of the PostScript standard that deals only with the programming structures is ~150 pages long), I would like to make sure that this will not be in vain.

If I understand correctly, pstricks macros eventually insert the PostScript code as \special with a certain structure, so in principle I should be able to redefine that primitive to send PostScript special to my interpreter.

The step that is not clear to me is how to go from there to actually producing graphics: presumably I would be using pgf. This leads me to a few related questions:

• Is it enough to simply hook into \special, or should I also change the pstricks macros that inserts spacing around figures, for instance?

• Is pgf powerful enough to express all elementary graphical operations of PostScript?

• Will I need a general purpose (e)ps to pdf converter?

• Suppose we have Herbert's this answer given which computes an integral(!?) 3d-plotting-sine-integral-pstricks. Skipping the other z buffering etc., shortcomings, PGF and PGFPLOTS combined might not be enough for the scary pst-func alone. There are other ODE solving possibilities etc. too. Do you plan to replicate the PSTricks overhead in the interpreter? Though I don't get how that would work, sounds just amazing. I'll wait for Herbert's response but still great initiative. – percusse Apr 23 '13 at 0:43
• From my point of view you should go the LuaTeX way of MetaPost, using a library which is then imported into the LuaTeX source. That is not a TeX solution but much more powerful. – user2478 Apr 23 '13 at 7:13
• You should have a look at Escrito. It's a PostScript interpreter written in Lua to be used from within LuaTeX. It's still in a very early stage. You may consider contributing instead of starting a project from scratch. – Marco Jun 10 '13 at 8:41
• You could also look at eps2pgf which is a postscript interpreter for converting eps to pgf. – Martin Heller Jun 15 '13 at 19:12
• Why not use TikZ directly? – Martin Ueding Jun 17 '13 at 11:21