1.2.1 UniTool, the Driver Data Table, and Printer Commands

The UniTool application provides an organized means of typing in printer data and command strings that become part of a minidriver's data table. Using this application, its menus, and its dialog boxes, a driver developer specifies data such as the supported text resolutions, graphics resolutions, paper sizes, font metrics, and so on. In addition, a developer specifies the printer commands which begin a document, end a document, select a paper size, select a paper source, reset the printer to its default state, and so on. In addition to specifying the data and commands described above, a developer can use UniTool to create device-font files and character-translation tables. The following illustration shows a main window for the UniTool application (the contents of this window vary from minidriver to minidriver):

1.2.1.1 Driver Resources

The minidriver contains four types of resources:

Printer-data resources

Font-data resources

CTT-data resources

String-table resources

The first three resource types correspond to three commands which appear in the application's main menu—when you enter values or printer commands in one of the application's dialog boxes, you're actually initializing or altering the data in one of these resources. The fourth resource type, string-table, contains strings that were specified in a number of the dialog boxes.

Note:

These resources are interrelated—when you alter one resource, it is likely that you will also need to alter another. For example, when you create a new font file using the Fonts menu and associated dialog boxes, you will also need to identify that font in the ModelData dialog box to indicate that it is supported by the model. From the Printer Data menu, choose the ModelData command to display the associated dialog box.

1.2.1.2 The Driver Data Table

The driver data table consists of 15 data structures. Following are the structures and a brief description of each:

Structure Description

COMPRESSMODE Identifies a data-compression mode and specifies the printer-command strings which select this mode. This structure also contains the printer-command strings which select the specified compression mode.
CURSORMOVE Specifies the limitations of the printer's cursor-movement commands. This structure also contains the command strings which move the printer's cursor.
DEVCOLOR Specifies the printer's color capabilities. This structure also contains the command strings which enable color output.
DOWNLOADINFO Specifies the printer-command strings which download fonts.
FONTCART Identifies a font cartridge. This structure also contains the printer-command strings which select the specified cartridge and identifies the fonts on that cartridge.
FONTSIMULATION Specifies the printer-command strings which enable and disable bold, italic, underline, and strikethrough font simulations.
MODELDATA Specifies the characteristics of a single printer model. (A single minidriver may support several models of a manufacturer's printer.)
PAGECONTROL Specifies the printer-command strings which initialize the printer, select the paper orientation, and so on.
PAPERDEST Identifies a paper output bin that collects pages. This structure also contains the printer command strings which select the specified bin.
PAPERQUALITY Specifies a media type (that is, plain paper, coated paper, or transparency) on which the printer is capable of printing. This structure also contains the printer-command strings which configure the printer for printing on a particular medium.
PAPERSIZE Specifies the dimensions of a piece of paper on which the printer is capable of printing. This structure also contains the printer-command strings which configure the printer for the specified paper size.
PAPERSOURCE Identifies a paper bin or feeding mechanism. This structure also contains the printer-command strings which select the specified paper bin or feeding mechanism.
RECTFILL Specifies the printer's rectangle-fill capabilities. This structure also contains the command strings which fill rectangular regions.
RESOLUTION Specifies a horizontal and vertical raster-graphics resolution that the printer supports. This structure also contains the printer-command strings which select the specified resolution.
TEXTQUALITY Identifies a text quality which the printer supports (that is, draft, near letter, or letter). This structure also contains the printer-command strings which select the specified text quality.

Most of the structures in the printer's data table correspond to one or more of the dialog boxes that appear in the UniTool application. By setting the controls in the dialog boxes, you actually initialize the members of these structures.

1.2.1.3 Predefined and Driver-Defined Values

A number of the UniTool dialog boxes specify predefined values that correspond to common paper sizes, paper qualities, paper sources, paper destinations, and text qualities. These same dialog boxes also provide a control in which you can type a driver-defined value; you should only specify a private driver-defined value if your printer does not support one of the predefined values. For example, there are five predefined text qualities:

Letter quality

Near letter-quality

Memo quality

Draft quality

Text quality

If the printer for which you are developing a minidriver supports a different text quality, you would type a string identifying that quality in the driver-defined control of the Text Qualities dialog box.

The following illustration shows the Text Qualities dialog box. The Predefined and Driver Defined controls appear at the top of the dialog box.

The predefined or driver-defined strings and values which you specify will typically appear when you choose an application's Printer Setup command and Printer Setup Options dialog box.

1.2.1.4 Device Commands

The structures in the printer-data table contain device-command strings. There are three formats that you can use to type command strings in UniTool:

Format Description

ASCII Literal ASCII characters can be typed as part of a command string.
Formatted parameter A formatted parameter is a parameter that is supplied by the Universal Printer Driver, and sent to the printer in a format based on the specified conversion characters. These conversion characters are always preceded by the % character. The following contains the conversion characters which are supported by the Universal Printer Driver, as well as a brief description of each.
Character Description

d The Universal Printer Driver will convert the parameter to a decimal value. (For example, the value 12 will be sent as '1' (31h) followed by '2' (32h).)
D The Universal Printer Driver will convert the parameter to a signed decimal value. This is the same as the %d character except it is preceded by a sign.
c The Universal Printer Driver will convert the parameter to a byte value. (For example, the value 12 will be sent as FF (0Ch))
l The Universal Printer Driver will convert the parameter to a 16-bit value with the Least Significant Byte (LSB) first. (For example, the value 12 will be sent as FF (0Ch) followed by NULL (00h))
m The Universal Printer Driver will convert the parameter to a 16-bit value with the Most Significant Byte (MSB) first. This is the same as %l except the order of the bytes is reversed.
q The Universal Printer Driver will convert the parameter to a unique hexadecimal value formatted for Toshiba and Qume devices.

Hexadecimal Hexadecimal values are preceded by the following two characters: \x. For example, the hexadecimal value 0xFF would be typed as \xFF in UniTool.

There are two types of printer commands which you will type in UniTool. The first type enables or disables certain features of the printer. For example, the command string ESCx3 enables letter-quality output of the Kodak Diconix 150 Plus printer. This command (ESCx3) is typed as \x1Bx\x03 in the Text Qualities dialog box. The string ESC was replaced by its ASCII representation (\x1B), the argument x was not altered, and the decimal value 3 was replaced by its hexadecimal equivalent (\x03). The second type of command contains parameters that are supplied by the Universal Printer Driver at runtime (when the command is used). For example, the Immediate Line Feed command for the Diconix printer is used to advance the cursor in the positive y-direction with respect to the current cursor position. The command string for the Immediate Line Feed command has the following syntax:

ESC J n

In this example, n is the number of 1/288th inch increments that the cursor will advance. The following illustration shows the Immediate Line Feed command typed in the CM_OCD_YM_REL control of the CURSORMOVE dialog box:

The “ESC” string was again replaced by its ASCII representation (\x1B), the argument “J” was not altered, and the variable “n” was replaced by the conversion character indicating that it is a byte value (%c).

1.2.1.5 Master Units

Most printers support commands with a variety of resolutions. For example,
the Immediate Line Feed command on the Kodak Diconix printer provides a
resolution of 1/288th of an inch while the same printer supports vertical-graphics resolutions of 1/96th of an inch. To simplify the problem of handling various resolutions, the Universal Printer Driver uses a single, common coordinate system. The units in this coordinate system are called master units. Master units are the least common multiple of the various horizontal and vertical resolutions supported by the printer. (For more information about master units, how they are computed, and how they are specified, see Chapter 3, “Specifying Master Units and Minidriver Data.”)

Converting Master Units

The Universal Printer Driver calculates the arguments for some printer commands by adding a value to the specified master units, multiplying the specified master units by a value, or dividing the specified master units by a value. For example, in the case of the Kodak Diconix printer, the vertical master unit is 1/576 of an inch; however, the printer's immediate line-feed command operates in 1/288 inch increments. When using this command, the Universal Printer Driver must convert the argument it supplies from vertical master units to the required units.

UniTool stores each printer command in a Command Descriptor (CD) data structure. In cases where the Universal Printer Driver will need to supply an argument to a particular command, such as the Immediate Line Feed command, UniTool stores additional data in an Extended Command-Descriptor (EXTCD) data structure. This data structure contains values by which the Universal Printer Driver should divide, multiply, increase, or limit command arguments. A special Units dialog box is provided for each printer command. In those cases where the Universal Printer Driver must convert master units, specify the appropriate values in the corresponding Units dialog box. In the case of the Immediate Line Feed command, master units must be divided by 2 prior to setting the parameter, therefore the sUnitDiv control contains the value 2 as shown in the following illustration:

The sMax control contains the value 255 (the maximum allowable value for this parameter) and the sMin control contains the value 1 (the minimum allowable value for this parameter).

Once you've read this chapter and understand the fundamental concepts of developing a minidriver, you're ready to set up the development environment. The next chapter, “Getting Started,” explains how this is done.