Typesetting with Perl

Subject tags: 

So recently I wrote a Perl script to automatically generate cover PDFs for a series of books I’m working on over at Wide Margin. This used the rather good PDF::API2 module to assemble the text and graphics onto the PDF. Now I’ve got the book in my hand, I’m a little bit disappointed by the typesetting of the blurb on the back cover.

This graphic shows the problem:

Guess how I solved it?

The premier typesetting software is TeX, and it uses a justification algorithm called Knuth-Plass. Here’s an implementation of Knuth-Plass in Javascript. So I ported it to Perl:

Not quite TeX-in-Perl, but sufficiently close for what I need.

Update 2010-01-31: And now with ligatures, paragraph indentation, TrueType kerning support, and non-French spacing. Must stop playing with this now and do some real work instead.


neverclickonthislink