EnscriptPrint

If you live in Emacs you would probably like to print things in pretty fonts once in a while. PsPrint is great for that, with a big limitation: limited font choices. Most people have tons of fonts in .ttf and other formats, not just the seven that Postscript printers typically offer. With this package that forms an interface to GNU Enscript, you can print in many pretty fonts, and highlight text for programming languages.

Code

I started this library as an interface to Enscript because I like printing in different fonts for different purposes: sometimes I’m in a Palatino mood, and sometimes I want something wicked like Comic Sans. I need fixed width fonts for printing source code, but I find Courier hard to read. Please submit patches and help me improve this package — I get a lot of mileage out of it, and I hope you will too. Todo items are in the source file marked with “TODO”.

Instructions

You will need:

Collect all the .ttf fonts on your system into a local ~/.fonts directory. I suggest something like

shell> cp `find / -name "*.ttf" -print0` ~/.fonts

Convert these ttf files to pfb, pfa and afm files using:

Create a font.map file for the current directory:

shell> mkafmmap *.afm

Edit your .enscriptrc to include /your/home/directory/.fonts in your AFMPath:

AFMPath: /home/emacs-lover/.fonts:/usr/share/enscript/afm

Check out the enscript FAQ [1] for any additional tips.

Features

Functions

The package defines the following user functions:

Suggestion

I customize enscript-after-hook with the following function:

(lambda nil
  (when preview-file
    (shell-command (concat "gv "
                           (expand-file-name preview-file) "&"))))

This hook launches an immediate previewer (gv).

Limitations

Discussion

Sounds interesting. I copied all of my TTF fonts to a test directory, to play with it. But then I found that I’m missing some of the pieces needed. I have Cygwin, but it apparently is missing these things:

Cygwin does have enscript, and the Enscript FAQ says that mkafmmap comes with the Enscript distribution, so I don’t quite understand why there is no mkafmmap.

Any ideas, anyone? Thx – DrewAdams

I tried this as well with cygwin, found mkafmmap no problems hashed as /usr/bin/mkafmmap. Also found mkafmmap using package search: http://cygwin.com/cgi-bin2/package-grep.cgi?grep=mkafmmap

I get a little further, when converting a font to afm:

$ mkafmmap DejaVuSansMono.afm
file=font.map
DejaVuSansMono.afm...
AFM Error: skipping key "DejaVu"

Seems to work for some other True Type Font though, I tried with LucidaTypewriterRegular?.ttf and had no problems. – DavidBoon