Printer Driver Design and Implementation Strategies
Windows NT includes RasDD for raster printing devices, a PostScript printer driver, and a plotter driver. Most currently available printers belong to the families supported by RasDD, the PostScript driver, or the plotter driver. Exceptions include devices that contain hardware drawing accelerators controlled by proprietary command sequences.
Each of these drivers have data-driven designs, allowing them to support broad classes of devices. Because these drivers customize their operation for specific printer models by interpreting printer data files, support can often be extended to a new printer simply by creating a new description file, rather than creating a new printer driver.
If a printing device is not supported in Windows NT, it should first be determined whether the device can be provided with minimum support using a minidriver and RasDD. There is no source for RasDD in the DDK, but if it is necessary to write a new raster printer driver, the designer can use a combination of the PostScript driver and the framebuffer (framebuf) display driver source as a model for such a driver.
The DDK includes sample source for a PostScript print driver in the print\psprint directory. The pscript subtree contains source code for the PostScript graphics driver, and the pscriptui subtree contains source for the PostScript interface driver. If it is necessary to create a new PostScript driver, modifying this driver should greatly reduce design time and effort.
The PostScript interface driver can provide a basis for a raster printer interface driver, with modification for the hardware. A major difference between PostScript and raster drivers is that a PostScript graphics driver writes to a device-managed surface, and so must implement certain rendering entry points. A raster driver, on the other hand, enables a GDI standard bitmap, allowing GDI to handle most of the rendering. The framebuffer display driver handles rendering in the same way. Some of the design areas that require close attention are the following:
·If the device has hardware fonts, the driver should support the DrvTextOut and the font query calls, including: DrvQueryFont, DrvQueryFontTree, and DrvQueryFontData. For more information, see Part 1 of this manual and the function descriptions in the Graphics Driver Reference.
·If the device supports scalable fonts, this must be indicated in the IFIMETRICS structure. GDI uses XFORMOBJ to determine the size of the fonts, which, in turn, determines the commands that must be provided to the printer. The PostScript driver uses scalable (transformable) fonts only, so review the textout.c file in the pscript sample driver as an example of implementing scalable fonts.
·It is important to be aware that the printer driver is in the same privileged kernel-mode address space as the rest of the Windows NT Executive. Faults in the printer driver will cause GDI and the rest of the system to fault. Driver writers can optionally implement a user-mode printer driver to perform rendering in user mode.
Supporting DDI Printing and User Interface Functions contains information on printer-specific driver entry points for the printer graphics and printer interface portions of a printer driver. It also lists the functions that comprise the user-mode printer driver module.