Printer Emulation - FujiNetWIFI/fujinet-firmware GitHub Wiki
Introduction
Several Atari printers are emulated to generate output available for download from the FujiNet's web server. So far these are:
- Atari 820
- Atari 822
- Atari 1020
- Atari 1027
There is also a file printer capability for capturing raw SIO buffers to a single binary file. This file printer can capture the entire buffer, trim the buffer after encountering an EOL (0x9B), or TRIM and convert EOL to \n.
Most of the printers are made to output PDF except the 1020 outputs SVG.
Testing
A number of short Atari printer test programs were found or written to test the emulated printers. Where possible, FujiNet output was compared side-by-side with real output or example output found in manuals.
PDF on FujiNet
The standard PDF document generation libraries are generally quite large and very flexible. For FujiNet a compact, custom, library was made to emulate the basic actions of the printers. For example, functions are implemented to output PDF code to start a new page, output a line of text, set the font, etc. The functions also keep track of file locations of all the PDF objects and builds a cross-reference table (xref) at the end of the PDF file.
Several resources were used to figure out how to generate PDF files on FujiNet:
- Make your own PDF file – Hello World is a great primer on how PDFs are assembled.
- PDF Reference, Third Edition - Adobe - at some point the actual specification is needed to learn the details.
- TextToPDF Apache PDFBox CLI Utility - Java program used to specify fonts and extract font parameters
- iText RUPS - Java program for inspecting PDF files and is useful for finding bugs
- novaPDF - Windows program for generating PDFs and used to embed Type 1 fonts.
- MS Word and Scientific Workplace (LaTex PDF) were used to generate basic PDFs, which were examined and dissected to learn by example.
Many specimen PDF files were generated by hand or by x86 C++ code to test out ideas. These can be found in the /pdf folder of the repo.
Printer Fonts
There are a few fonts in the wild that are close to the Atari printers' but often nothing is an exact match. Fonts in use for printer emulation include:
- Atari 820 - Custom Atari 820 Normal and Atari 820 Sideways fonts were generated based on real printer output. At first this 5by7 font was used for the normal font; however, it had to be modified with FontForge to make it monospace and to encode in Windows ANSI. It was also modified in FontForge to make the sideways font but has since been replaced with the accurate custom font.
- Atari 822 - A custom Atari 822 Thermal font was generated based on real printer output. At first this 5x7 Matrix font was used, but the lower case characters are not a good match in vertical placement.
- Atari 1020 - FifteenTwenty is from those other guys but have to grudgingly admire the ingenuity. This font is not complete and is missing the international characters available on the 1020. Eventually emulation will use the original vector table to draw SVG paths instead of the font.
- Atari 1027 - Prestige Elite is a near perfect match. Some notable difference include: ampersand is E-shaped rather than S-shaped; single quote is an acute; tilde is elevated; caret is squashed and elevated; curly braces are blanks; the international character set contains a "Latin Capital letter I with ring above."
- Epson - plan to use the amazingly thorough FX Matrix font family
Font Development
The following workflow is followed to make fonts for FujiNet:
- FontStruct is useful for making matrix fonts. The shape, size and spacings of the dots can be adjusted (using the Filter feature). Characters are place right on the baseline. Uniform spacing of width+1 is set in the Preview pane. A TTF font file can be downloaded for free.
- FontForge is used to clean up the font and create an OTF font from the TTF. With the FontStruct TTFs for the 820 and 822, the following steps were done: Re-encode to Windows ANSI; remove spurious codes and glyphs; copy space to blank characters; change the Em size to 1000; uniform scale relative to the glyph origin by 70% to get the height right; round to the nearest int; find extrema; set the Windows font parameter ascent to 1000 if needed and change x height to actual;save as an OTF.
- Install the OTF to the operating system (Windows)
- Create a simple Word document in the font and print a PDF using novaPDF. The option to embed the entire font is selected.
- Use a HEX editor to remove everything from the PDF except the FontFile object contents, which is saved into the fujinet data directory.
- Transfer the metrics (e.g., widths, capheight, xheight, etc) from the PDF to the FujiNet source.