Old font utils written in BASIC for DOS (now rewritten in FreeBASIC)
![]()
Two small font tools from the DOS age. POLFED32 edits DOS text-mode bitmap fonts pixel by pixel; METRXPRS fixes the metrics of composite glyphs in Adobe .AFM files so an Aacute lines up with its A. Both were written in BASIC in the late 1990s, then rewritten in FreeBasic (2015) so they still compile and run on Windows and Linux today.
Status: archival. These are stable, mature, single-purpose utilities kept here for retrocomputing and legacy font-production work. Expect no new features — bug reports are still welcome.
Published under the Apache 2.0 License.
Author: Adam Twardoch adam@twardoch.com Contributors: Adam Twardoch adam@twardoch.com Homepage: https://github.com/twardoch/dos-font-utils
This project provides two main utilities:
POLFED32.EXE is a powerful command-line editor for creating and modifying bitmap screen fonts, primarily those used in DOS text-mode environments. It allows for pixel-level manipulation of glyphs within a font file.
METRXPRS.EXE (Metrics Express) is a “metrics assistance” tool designed to process Adobe Font Metrics (.AFM) files. It corrects the metrics of composite glyphs (e.g., Aacute) to align with their base glyphs (e.g., A) based on user-defined equality tables.
.AFM files according to specified parent-child glyph relationships in a .MEQ file.These tools are primarily for:
Pre-compiled Windows executables (POLFED32.EXE, METRXPRS.EXE) are provided in their respective subdirectories (POLFED/ and METRXPRS/). These are command-line tools.
cmd.exe) or PowerShell.POLFED16.EXE), an emulator like DOSBox would be required.No special installation steps are typically needed other than placing the executables in a directory that is in your system’s PATH or navigating to their directory to run them.
The tools are written in FreeBasic and can be compiled using the FreeBasic compiler (fbc).
METRXPRS.EXE:
cd METRXPRS
fbc -lang qb METRXPRS.BAS
POLFED32.EXE:
cd POLFED
fbc -lang qb POLFED32.BAS
The -lang qb option is used for compatibility with QBasic syntax elements.
POLFED32.EXE INPUT.EXT [OUTPUT.EXT]
INPUT.EXT: The path to the input font file. The file extension determines the expected character height:
.CGA: 8 pixels high.EGA: 14 pixels high.VGA: 16 pixels high (e.g., DOSFONT.VGA).XGA: 20 pixels high.F<nn>: Custom height, where <nn> is a number from 4 to 20 (e.g., .F10 for 10 pixels high).[OUTPUT.EXT]: (Optional) The path to save the modified font file. If omitted, POLFED32.EXE will overwrite the INPUT.EXT file upon saving.Upon execution, POLFED32.EXE opens an interactive text-based user interface (TUI) to edit the font. See the “POLFED32.EXE Internals” section for more on its features.
Example:
POLFED\POLFED32.EXE POLFED\DOSFONT.VGA POLFED\MYFONT.VGA
Direct programmatic use of POLFED32.EXE is not its primary design. However, one could automate its execution via shell scripts if batch processing of font files is needed, though interaction with its TUI would be complex to automate. The font file format itself (raw bitmap data) is simple and could be generated or manipulated by other custom programs.
METRXPRS.EXE <AFM-INFILE> <AFM-OUTFILE> <MEQ-FILE>
<AFM-INFILE>: Path to the source Adobe Font Metrics (.AFM) file that needs correction.<AFM-OUTFILE>: Path where the corrected .AFM file will be saved.<MEQ-FILE>: Path to the “Metrics Equality” file. This plain text file defines which child glyphs should inherit metrics from which parent glyphs. (See MEQ File Format for details).Example:
METRXPRS\METRXPRS.EXE METRXPRS\ORIG.AFM METRXPRS\METR_corrected.AFM METRXPRS\ANSI.MEQ
This command will process ORIG.AFM using rules from ANSI.MEQ and save the result to METR_corrected.AFM.
If incorrect arguments are provided, or if /h or /? is used as an argument, the program will display a help message with syntax instructions.
METRXPRS.EXE is well-suited for programmatic use in scripts or build processes due to its command-line nature and distinct input/output files. It can be easily integrated into automated font production workflows.
POLFED32.EXE is a sophisticated text-mode application that provides a visual environment for editing bitmap fonts.
POLFED32 works with raw binary font files.
.CGA: 8 lines/bytes.EGA: 14 lines/bytes.VGA: 16 lines/bytes.XGA: 20 lines/bytes.F<nn>: Custom height from 4 to 20 lines/bytes..VGA font with 256 characters would be 256 * 16 = 4096 bytes in size.The editor presents a Text-based User Interface (TUI):
ALT+H through multiple help screens).0: Clear character5: Invert character (flips black/white pixels)7: Horizontal mirror9: Vertical mirror8, 2, 4, 6 (numpad): Shift character pixels up, down, left, right respectively.Alt+P (in editor): Pattern fill (repeats the current pixel pattern downwards).F1-F4: Copy current character to clipboard buffer 1-4.Ctrl+F1-F4: Paste from clipboard buffer 1-4 to current character.Shift+F1-F4: View character in clipboard buffer 1-4.Alt+F1-F4: Clear clipboard buffer 1-4.Backspace key provides a single-level undo for the last modification to a character.Alt+X: Prompts to save and exit.Alt+Q: Prompts to quit without saving.F9 toggles sound effects.F10 cycles through different pixel display styles.The POLFED directory also contains POLFED16.EXE. This is an older version of the editor, written in Visual Basic for DOS.
METRXPRS.EXE processes AFM files based on rules in a MEQ file.
The program (METRXPRS.BAS) operates as follows:
MEQ-FILE. Each line is parsed into a child glyph name and a parent glyph name.MEQ$).UNQ$).AFM-INFILE is read.C ... N <glyphname> ...), if <glyphname> is in the list of unique parent glyphs, its metrics (character code, width WX, and bounding box B llx lly urx ury) are stored.AFM-INFILE is read again, line by line.AFM-OUTFILE as-is.MEQ$ array:
WX, B0 (llx), and B2 (urx)) of the parent glyph are used to replace those of the child glyph. The B1 (lly) and B3 (ury) values, as well as the character code and glyph name, are preserved from the original child glyph entry.AFM-OUTFILE.The core logic ensures that composite characters like ‘Aacute’ will have the same width and horizontal bounding box extents as their base character ‘A’, if specified in the MEQ file.
The Metrics Equality (.MEQ) file is a simple plain text file.
<child_glyphname> <space> <parent_glyphname>Aacute A
Agrave A
eacute e
This tells METRXPRS.EXE to adjust the metrics of Aacute and Agrave based on A, and eacute based on e.
Sample files ANSI.MEQ, ORIG.AFM (input example), and METR.AFM (output example after processing ORIG.AFM with ANSI.MEQ) are provided in the METRXPRS directory.
As these tools are written in FreeBasic (with QBasic compatibility - -lang qb), any contributions to the .BAS source files should aim to:
REM or ') to explain complex sections.$, integer variables may have no suffix or %).SUB and FUNCTION for procedures where appropriate.-lang qb dialect if modifying existing logic.This project is maintained by Adam Twardoch. While it’s a relatively small and mature project, contributions in the form of bug reports or feature suggestions are welcome.
dos-font-utils repository.Please ensure any contributed code is also licensed under the Apache 2.0 License.