To fully support Unicode, Windows NT has changed the format of the Windows 3.1 CTT to the new RLE format. RasDD can still use the old format (for compatibility with 16-bit minidrivers), but the RLE format supports the wide characters of Unicode and speeds up CreateDC calls by having much of the font information precomputed in the format required by GDISrv.
The CTT file contents can be saved into one of three formats. Unitool determines which one is to be used to save the CTT file based on the information that was entered as follows:
·1-to-1 (byte to byte) translation (effectively a translation table). Each character code consists of a single byte. For simple remappings, RasDD sends the character value entered in the edit control each time the ASCII value is shown.
·2-to-1 (two bytes to one byte) translation. Each character code consists of either one or two characters. RasDD sends the first character value entered in the edit control, then uses either a backspace or x-movement command (as defined in the DI_BKSP_OK control) to move from the current position back to the original position. Then RasDD sends the second character to overprint the first. If null, the second character is not sent. This is used to overstrike characters, such as the slash and zero to produce a slashed zero.
·Variable-length (byte to byte) string translation. Each character code consists of a variable length string containing printer commands that can change printer modes to gain access to a particular character, such as symbol set switching in the LaserJet family. RasDD sends the commands entered in the edit control when requested.
The differences between these formats is transparent to the user. Unitool creates the CTT in a format that results in the smallest file size depending on the actual translation. Printer commands sent from the CTT do not change the permanent state of the printer.
The Window NT equivalent of these is the RLE table. Because Unicode is a somewhat sparse mapping and real fonts are even sparser, there is a need to have the capability to return information about which glyphs are available in the font to GDISrv. This is done using the WCRUN structures defined in the winddi.h header file. To speed up CreateDC, RasDD uses these same structures in the minidriver. This means no time is spent building up tables that are static for a given printer.
The Windows NT DDK provides the ctt2rle tool to convert an existing Windows 3.1 CTT file to an NT RLE file. The conversion is done assuming that the Windows 3.1 character set provides the input mapping. The ctt2rle executable requires only a single parameter: the file containing the CTT data. The output is written to a file with the same prefix, but with a .rle extension. Similar to Unitool, ctt2rle uses the shortest format available to encode this information. The sample drivers in the DDK contain a batch file showing how ctt2rle.exe is used to convert existing files.