What's on this page: Intro ... download ... features ... documentation ... Email me
Mirrors: US/Geo ... US/SF ... UK ... Russia

txtbdf2ps -- translator TXT + BDF to PS

This is a perl script that can generate compact, DSC-compliant Postscript out of a plain text file and a BDF font. The output can be previewed using Ghostscript under most platforms, or with the Windows shareware program "ROPS", or printed on Postscript printers, or converted to PDF using "ps2pdf".

The script is in public domain.

The motivation for creating this script was to be able to print texts in international character sets. Since it's much easier to create or edit bitmap (BDF/PCF) fonts than outline fonts, this script allows to print texts using your own fonts. The future goal is to implement some more formatting options. Unicode is supported (as of version 0.7).


(Download the file and rename it as "txtbdf2ps". The development version "works" and includes new features but is not tested as much.)

New in development version: initial Unicode (UTF-8) support for input text and BDF fonts (no combining accents yet, and at most 65535 chars). Experimental support for left-directional scripts (Arabic, Hebrew, ...) and Arabic shaping (in version 0.7.1).

New in stable version: code rewrite; reduced PS file size; better indentation and diagnostics.


A reasonably complete collection of fixed-width Unicode BDF fonts is maintained by Markus Kuhn and available here. The resolution is low but there are lots of characters.

Download a proportional-width (low-res.) Unicode BDF font "ClearlyU".

For Cyrillics: Download a sample high-resolution BDF Cyrillic font in KOI8-C encoding (download this file and unpack it). This 720 DPI font was made using the free program ttf2bdf out of the free Times New Roman Unicode font downloadable from the Micro$oft site and edited using the free program xmbdfed. You can take your own TTF fonts and convert them to high-resolution BDF and your printer won't notice the difference! (And you can edit the results, too.) More information about the new KOI8-C Cyrillic encoding, as well as a set of free BDF KOI8-C Cyrillic fonts, can be found here.

Finally, here's the famous Cyberbit font from Bitstream: a 13 MB TTF monster with a somewhat reasonable coverage.

Script requirements: perl 5.x. (Ghostscript is recommended for previewing but not required. The output it tested on Ghostscript under Unix and ROPS under Windows.) The script should work under any platform that supports perl, since all it does is manipulation of ASCII files.

Current features


To get brief documentation, run "txtbdf2ps -help" and you will get the following:

Script by Serge Winitzki. Version 0.7
Sample usage:   txtbdf2ps [options] < input.txt > output.ps
        cat fontfile.bdf input.txt | txtbdf2ps [options] > output.ps
Options: (the BDF file and the text file are required of course)
 -help  print this help message
 -bdf=BDFfile.bdf       use BDF file as text font (give full path if necessary)
 -text=textfile.txt     read given text file (ditto)
        default is to take BDF and/or text input from STDIN
        if taking both from STDIN, the BDF file *must* go first
 -justify       justify text, compress spaces between words (default not to)
 -nowrap        break lines exactly as in text and do not wrap any lines
        (default to wrap until paragraph ends: empty line, TAB, 4+ spaces)
        "-justify -nowrap" means no wrapping but leave only one space between words
        warning: with -nowrap, lines that are too long will *not* be wrapped.
        otherwise, any words that do not fit will be broken across lines
Size options: (all parameters are floating point values unless indicated)
 -fontsize=XXX  use given font size (default 12.0)
 -page=XXX      use given page size (default smallest of letter and A4)
        page may be "letter", "A4", or exact bounding box "XX,XX,XX,XX"
        e.g. "-page=letter" or "-page=0,0,612,792" (integers and no spaces!)
 -lineskip=XXX  set relative lineskip amount (default 1.1)
 -gap=XXX       insert additional horizontal space between letters in units of font size
        (default 0, XXX=1 means insert a gap "fontsize" points wide)
 -indent=XXX    set paragraph indent in units of fontsize (default 1.5)
 -tab=XXX       set tab expansion as the # of space chars (integer)
        default: same as the -indent value if given, or else 8
 -margin=XXX    set margin size relative to page size, for each margin
        (default 0.05)


Write to me!