pbmtext
Convert text to a portable bitmap image
TLDR
Render a single line of text as a PBM image
Render multiple lines of text as a PBM image
Render text using a custom font supplied as a PBM file
Specify the number of pixels between characters and lines
SYNOPSIS
pbmtext [-font fontname] [-builtin] [-angle degrees] [-lisp] [-width width] [-height height] [-indent indent] [-rle] [text]
PARAMETERS
-font fontname
Specifies the path to a font file (e.g., .pbm or .bdf format) to be used for rendering the text. If not specified, the built-in font is used by default.
-builtin
Forces the use of the built-in font, ignoring any -font option. This is the default if no font is specified.
-angle degrees
Rotates the text clockwise by the specified number of degrees. The angle can be a floating-point number.
-lisp
Formats the output for Lisp systems, typically used for specific internal Netpbm operations or testing.
-width width
Sets the maximum width of the resulting PBM image in pixels. Text lines longer than this width will wrap automatically.
-height height
Sets the maximum height of the resulting PBM image in pixels. If the text exceeds this height, it will be truncated.
-indent indent
Indents the text by the specified number of pixels from the left edge of the image.
-rle
Outputs the PBM image in run-length encoded (RLE) format, which can be more compact for certain types of images.
DESCRIPTION
pbmtext is a command-line utility from the Netpbm suite that generates a portable bitmap (PBM) image from specified text. It renders text using either a built-in font or an external font file, producing a monochrome (black and white) image where the text appears as black pixels on a white background (or vice-versa, effectively).
This tool is commonly used in scripting contexts to dynamically create image labels, titles, or simple graphical elements that can then be combined with other images using Netpbm's extensive set of tools. It's particularly useful for generating programmatic image overlays or for environments where graphical user interfaces are not available, relying instead on terminal-based operations and piped output.
CAVEATS
pbmtext is designed for simple text rendering. It does not support advanced text formatting features like bold, italics, varying font sizes within the text, or complex layout. The quality of text rendering is highly dependent on the chosen font's resolution. External fonts must be in a format supported by Netpbm, typically .pbm or .bdf.
Also, character encoding issues can arise if the input text contains characters not present in the chosen font or if the system's locale doesn't match the font's encoding expectations.
INPUT AND OUTPUT
pbmtext can take its text input either directly as arguments on the command line or from standard input (stdin) if no text arguments are provided. The resulting PBM image is always written to standard output (stdout), making it highly suitable for piping with other Netpbm commands or redirecting to a file.
FONT HANDLING
While pbmtext includes a basic built-in font, for higher quality or specific aesthetics, users often supply custom font files. These external fonts typically need to be in a bitmap format compatible with Netpbm, such as a PBM font or a BDF (Bitmap Distribution Format) file, which can be generated or converted from other font formats using tools like fontforge or pbmtofont.
HISTORY
pbmtext is an integral part of the Netpbm package, which originated from Jef Poskanzer's Pbmplus toolkit in the late 1980s. Pbmplus (and subsequently Netpbm) was developed to provide a comprehensive set of command-line tools for manipulating portable pixmap, grayscale, and bitmap (PPM, PGM, PBM) images. pbmtext has been a core component since these early days, reflecting the foundational need for text-to-image conversion in a Unix-like environment, often used in conjunction with other pipeline-oriented image utilities.