Friday, October 03, 2014

Typewriterisms

I feel sort of bad. But it was something that I needed at some point given my various experiments.

I wrote this recently and pushed it out on my personal domain: Typewriter-like Line Printer Emulator. I had to; it needed to be done.

There wasn't an easy way to capture the output from a text file (or typewriter-like input) into a PDF or something of that sort. One's at the mercy of the multitude of printer drivers that are out there, which demanded all kinds of... things.

Even notepad/vim is hopeless at this. Control over the number of lines and columns in the page are non-existent.

And cute typewriterisms like overstriking ____________ are missing.

And non-cute typewriterisms like the bad register of the keys on impact.

Of course, apart from the more obvious fun factor of figuring out how to emulate all these line-printer analogues in the precise nature of the digital realm, there are some other practical aspects of it.

It is of no secret that I have an interest in typography in a while. Typography and typesetting. I know LaTeX and even groff/troff/nroff exist and enjoy what they do, but somehow something is lacking. That old rustic charm from an antiquated means of typesetting, the world of monospaced fonts. The type of output one would find in say HAKMEM. It's not practical I know, but to me, it's the artistic merits of it.

And so that's my side project. To build stuff that recreates the old processes in a way that is still usable even in the modern era. Which of course explains the monstrosity that I linked to earlier.

Conceptually, it's simple. All it does is to take in a stream of ASCII characters from stdin and dump them to stdout which can be redirected into a PostScript file in a way that is consistent with a typewriter. This means, of course, the use of Courier (for now), and requiring a predefined paper size as well as font size. The program merrily dumps each line from the input stream to the output stream subjected to the ``physical'' constraints of the defined paper and font size. The outcome is a barebones PostScript file that can be sent into a post-processor to convert into a PDF or some other format.

It doesn't handle the typesetting of the page, or even the enforcement of line wrapping for the current trend of ``single-line paragraphs'' like this blog post. We have other programs for that (think fmt and par) for now---I will be rewriting some of these for my own needs later on.

One big beef is the lack of handling of Unicode, which I will look into once I can figure out how to get a pan-unicode monospace font to work with PostScript (yes, I am looking at GNU Unifont for this).

We'll see how it goes.

On another note, here's an example output of this blog post using the tool and some pre and post processing chains:



Till next time.

Edit: Adjusted to provide the PDF version on click.

No comments: