Tuesday 14 July 2009

Enhancements to the Command Line Utility

Today I implemented a challenge-response style persistence mode to the command line utility. Usually, the command line utility — which ships as part of mathtex — exits as soon as it has finished rendering the equation.

However, in persistence mode, which is invoked by providing no output file it works as follows:
./mathtext
$x+y=2$
/tmp/tmpg0gkiX.mathtex.png
$xy=4$
/tmp/tmpCqTVBH.mathtex.png

Upon entering persistence mode mathtext waits for an equation on stdin; after an equation has been typed in it is rendered and the filename — generated automatically — is written to stdout. This not only makes batch processing of equations easier but also makes it a lot more convenient to use mathtex in another application.

Rather than having to spawn a new instance of ./mathtext every time you need to render an equation you instead can just launch a single instance and pipe equations to it. This is significantly faster than spawning a new instance.

The resulting equations remain in the systems temporary directory until the caller deletes them. Alternative file formats are available by using the -j flag.

3 comments:

  1. Fantastic Work!!

    Will this externilization allow it to be used in IronPython?

    ReplyDelete
  2. The code currently depends on a module called FT2Font. This is a wrapper around FreeType written in C++. If a .net equivalent could be written (same API, but using the .net font libraries) then yes, it could be used.

    ReplyDelete