ZX Spectrum font conversion, ripping and manipulation tool for 8x8 bitmap fonts.
This is a tool I have been using for a number of years to convert my own fonts into a variety of formats available from https://damieng.com/fonts/zx-origins/
It also contains bulk-ripping dump and hunt commands for obtaining ZX Spectrum RAW 768 byte/.ch8 files from memory dumps and snapshots.
dumpto RAM-dump snapshot files (currently supports.z80and.snaand recurses through.ziparchives)huntto look through RAM dumps for possible bitmap fonts (currently supports only ZX Spectrum fonts)screenshotto create a screenshots from RAM-dumps or snapshot files (in PNG, SCR or animated GIF format)extracttilesto create a files with unique 8x8 character tiles found on the screen in RAM-dumps or snapshot files
The following commands work with ZX Spectrum RAW 768 byte/.ch8 files:
previewto create a.pngpreview filepngtozxto convert a.pngback to a ZX Spectrum.ch8c64tozxto create a ZX Spectrum.ch8file from a C64 binary file
Any of the following assembly generating commands can use the --base hex|decimal flags. The z80 one can also use --base binary.
z80asmto create Zilog Z80 assembler source withdefbhexx86asmto create Intel 8086 assembler source withdbhex6502asmto create MOS 6502 assembler source with.bytehex68000asmto create Motorola 68000 assembler source withDB.Bhex
And the header-generating commands:
cheadto generate C-compatible header filesrustheadto generate Rust-compatible header files
You can also generate directly-usable files (all binary except the CPC)
zxtofzxto create a fixed-width.fzxzxtofzx --proportionalto create a proportional.fzxby auto left aligning and measuring widthszxtocbmto create.c64and.binbinary ROM versions for the Commodore 64zxtoa8to create a.fntbinary version for the Atari 8-bit serieszxtocpcto create a.basBASIC file for use with the Amstrad CPC range
findmatchesto find glyphs from a source font in as many possible target .ch8 files
Any command can be further detailed using the --help option which will detail the additional flags and options available.
Finding bitmap fonts in a raw memory dump isn't trivial as there's no specific header however there are a few different strategies available in the code that can be combined and tweaked, they are:
This relies on programmers using the ROM routines to print text to the screen and is surprisingly successful. It basically looks for a font at whatever RAM location is specified at memory locations 23606 & 23607. It can only find one font however so games like Millionaire that use several get missed.
This looks for fonts based on well-known glyphs that designers rarely changed such as the copyright symbol and by using their known position in the font works out where the font is located.
This provides an array of potential glyphs without any knowledge of what they actually are. It requires you pass a certain number of glyphs and looks to find a minimum amount of them in a sequence in RAM.
This works in conjunction with SpectrumDisplay.GetCandidates to divide the current screen memory into as many unique 8x8 character blocks as it can. The principle here is that the font is probably used on-screen and is aligned to the usual (32x24) text grid.
This finder looks for fonts by expecting certain pixel densities in relative to each other. For example ! should have less pixels than m. c should have less pixels than o etc.
The project should compile with VS 2019 or later.
Some template files are necessary for the conversions and should have their location specified by the --templatePath parameter.
atari8.fnt- A dump of the Atari system font that includes all the symbols characters etc.c64-both.c64- A dump of the Commodore 64 upper+lower casec64-upper.c64- A dump of the Commodore 64 upper case + symbols
Various different usages of this command can be fount in my ZX Origins font-publishing script - every reference there to pw.exe is this.