APPLICATION NOTE #170 ADDING 3RD-PARTY FONTS TO AN ADVANCED LASERJET PRINTER Rev. 04 Most Hewlett-Packard LaserJet printers support downloadable soft fonts in addition to the internal fonts supplied with the printer. Soft fonts are available from Hewlett-Packard and from other font manufacturers. The printer files you received with XyWrite define only the Hewlett-Packard soft fonts. If you purchase a compatible soft font from a different manufacturer (a third party), you can modify your printer file to accommodate it. This application note gives you the information you need to make the required changes to the printer files for a LaserJet IID, IIP, III, IIID, IIIP, or IIISi printer file. Before beginning, review the portion of the XyWrite Reference Guide that describes printer files. CREATE A NEW PRINTER FILE When adding a soft font, we recommend that you create a new printer file instead of modifying the standard file. There are two ways you can handle this task. One is to run a program called XPT, which is available from Lodestar Communications, P.O. Box 2870, Canoga Park, CA 91306. XPT reads the actual font file and then generates a complete XyWrite printer file, including PT (Print Type) tables. Alternatively, you can use the NEW command to create a new file, merge the contents of the appropriate LaserJet printer file into it, and then modify the new version. For example: Type: F5new 3hp-new.prn,3iid-sft.prn The following sections describe the areas of the printer file that you modify to add a font. These areas include the comments section, PT tables, font tables, width tables, and character substitution tables. When you are adding soft fonts that are fully compatible with Hewlett-Packard LaserJet IID, IIP, or III printer, you do not need to change the initialization settings (FB<, FE<, LE<, PE<, PG<), attribute tables, vertical spacing table, or microjustification settings. MODIFY THE COMMENTS SECTION Every customization file starts with a file label that tells XyWrite what type of file it is. The file label for a printer file is ;PR;. If this label does not appear on the top line of the file, type it in. (Be sure to type it in uppercase.) Next, move the cursor to the section that lists the supported fonts. The purpose of this optional section is to provide, for quick reference, the abbreviation and full name of every font defined in the printer file. The first line of each font description starts with the manufacturer's font code and font name; subsequent lines contain the abbreviation and full name of each type style in the font. The abbreviations, which usually incorporate the point size and an abridged font name, are used throughout the printer file as the font labels. The following is an example of this format. ; HP 33412ea SOFT FONTS: Prestige Elite ; ; 10PE 10-point Prestige Elite ; 10PE-BOLD 10-point Prestige Elite bold ; 10PE-ITALIC 10-point Prestige Elite Italic ; 7PE 7-point Prestige Elite Using the same format, type in the number, name, and abbreviations for the fonts you are adding. Note that each line starts with a semicolon to distinguish it from a XyWrite command. The semicolon convention is used for comment lines throughout the printer file. CREATE A NEW PT TABLE PT (Print Type) tables enable XyWrite to actually use the fonts once the proper codes are written into the file. The PT table numbers correspond to the value you use with the PT (Print Type) formatting command. For example, if you issue the command: F5pt 1 XyWrite looks at the table labeled PT=1 in the current printer file. You must add each font you want to use to a PT (Print Type) table. The easiest way to begin is to define an existing PT table and copy it to the end of the PT section. 1. Page down until you see the PT tables. 2. Define the last PT table. For example, if PT=6 is the last table in the section: Move your cursor to the beginning of the PT=6 line and press F1. Move your cursor to the end of the PT table (marked by a semicolon and a carriage return) and press F1. Result: This defines the table PT=6 as a block. 3. Press: F7 (to copy the block) 4. Press: F3 (to release the defined block) 5. In the new table, change the 6 in PT=6 to the next available number (e.g., PT=7). 6. Change the font name in the new table. The name can be anything you want as long as it does not contain any spaces or a plus sign. Once you choose a name, you must use it everytime you refer to this font in the printer file. We suggest you use the font's point size and an abbreviation of the typeface as the font name. For example, if your font is a 9-point Helvetica, you could call it 9HELV. If you are actually adding three fonts (normal, bold, and italic), add the ÿ2DBOLD extension to one name and the -ITALIC extension to another. It is not necessary to change either the modes (MD NM, etc.) or the attributes (underline, etc.) in the PT table. An example of a completed PT table is shown below. PT=7 MD NM+9HELV MD BO+9HELV-BOLD MD UL+9HELV+UNDERLINE MD RV+9HELV+FORMS MD BU+9HELV-BOLD+UNDERLINE MD BR+9HELV-ITALIC MD SU+9HELV+SUPERSCRIPT MD SD+9HELV+SUBSCRIPT ; If you want a blank line between PT tables, make sure you put a semicolon on the blank line as shown above. 7. Save the changes to disk. Type: F5save CREATE NEW FONT TABLES Font tables translate the names used in the PT tables into font codes that the printer understands. Font tables also contain the value of the vertical leading associated with the font and references to both a substitution table and a width table. You need to create a separate font table for each font. For example, 9HELV, 9HELV-BOLD and 9HELV-ITALIC require separate tables. The following example is for a 9-point Helvetica font. FO:9HELV FO<{esc}(8U{esc}(s1p9h9v0s0b4T VL=46 UW:9helv US:Roman8 ET The first line defines the name of the font table. You must use the same name that you used in the PT table (e.g., 9HELV for 9-point Helvetica or 9HELV-BOLD for 9-point Helvetica Bold). The second line contains the control codes that the printer needs to process the font you are defining. The escape codes for Hewlett-Packard fonts have the following general format (note that the character after the ampersand is a lowercase L): {esc}(n1{esc}(sn2pn3hn4vn5sn6bn7T n1 is the character set (for example, 8U for Roman-8, 0U for ASCII, 0A for Math-7, 8M for Math-8, 1U for Legal) n2 defines whether the font is monospaced (0) or proportional (1) n3 defines the horizontal size of the font (use the point size) n4 defines the vertical size (use the point size) n5 defines the slant of the font (0 for normal, 1 for italic) n6 defines the boldness of the font (0 for normal, 3 for bold) n7 defines the typeface family (e.g., 0 for line printer, 3 for Courier, 4 for Helvetica, 5 for Times Roman, 6 for Letter Gothic, 8 for Prestige, and 11 for Presentation). Refer to the LaserJet IID, IIP, or III Printer Operator's Reference Manual to determine the Hewlett-Packard control codes that define your new font. In the sample font table shown above, the font statement defines a font that uses the Roman-8 symbol set (8U). The font being defined is a proportional one (1p) that is 9 points (9h and 9v). It has a normal slant (0s) and a normal weight (0b), and is from the Helvetica family (4T). Line three contains the VL (Vertical Leading) command, which defines the vertical spacing for the font. This is the value XyWrite looks at when automatic leading is turned on. The VL setting can be calculated using the following formula: [(Size + modifier) X VMI]/72 = Size refers to the point size of the font. The modifier allows for extra white space between lines. We recommend that for point sizes between 1 and 8, you use a modifier of 1. For point sizes between 9 and 14, use 2. Over 14, use a modifier of 3 or more. The VMI (vertical motion increment) is the smallest vertical movement the printer can make; for LaserJet printers using downloaded soft fonts, this value is 300 (1/300th of an inch). The number "72" refers to the number of points in an inch. By solving the equation, you can determine the VL setting that should be used with the font. Let's use the 9-point Helvetica example to calculate the value for VL. The point size is 9, which falls within the range of point sizes that use a modifier of 2. The minimum vertical unit (or VMI) of the LaserJet IID, IIP, and III is 1/300th of an inch. So our equation is: [(9+2) X 300]/72 = VL You can use XyWrite's math capabilities to solve this equation by typing the following command. Type: F5((9.00+2.00)*300.00)/72.00= The result of this equation is 45.833333. However, since the VL setting must be a whole number, round off the result to 46. If you prefer to have your output set more tightly or loosely, you can modify this value until you are satisfied with the results. On line four (UW:), enter the name of a character width table that corresponds to the font. Without this information, the printer file will not load successfully. Similarly, enter the name of a character substitution table on line five (US:) if your font requires this. If your font uses the Roman-8 or PC-Line symbol sets, enter Roman8 or PCLine. Fonts that use the ASCII symbol set do not require a substitution table; for those fonts, remove the US: line. If your font uses a different symbol set, you need to create a substitution table, as described later. Decide on the name you want to use for the substitution table and enter it here. You can name this new table anything you want, but don't use spaces. An ET (End Table) command completes the table. Before moving on to the next step, remember to SAVE your file. GENERATE NEW WIDTH TABLES XyWrite uses character width tables to calculate accurate line endings and to produce microjustified text. Several fonts may have the same width values and thus use the same width table. For example, all 12-pitch monospaced fonts use the same widths, so you don't need to create a width table for Prestige, Prestige Bold, and Prestige Italic. Even some proportional fonts use the same widths. For example, a 10-point Century font may use the same widths as a 10-point Times font or a 10-point Helvetica font may use the same widths as a 10-point Helvetica Oblique font. To save memory, avoid including unnecessary width tables; just be sure that the UW (Use Width) line in the font table references the correct width table name. The following is a portion of a width table for a 9-point Helvetica font. WD:9HELV SW=22 il=9 '`j=10 ,.If=11 . . . W=36 @=41 ET ; The first line of the table contains its name, as referenced in the UW: line of the font table. Subsequent lines define the character widths. SW (Standard Width) defines the most common character width for the font. Exception widths (proportional fonts only) are listed after the standard width. If a character is not listed specifically XyWrite assigns it the standard width. Character widths are expressed in multiples of the minimum horizontal unit. For LaserJet IIDs, IIPs, and IIIs, the minimum unit is 1/300th of an inch. If a character's width is 25/300ths of an inch, the value entered in the table is 25. An ET (End Table) command completes the table. There are three ways to determine the character widths: * Refer to the information supplied by the font manufacturer. Some manufacturers provide width information with their soft fonts. * Run CTABLE. CTABLE is a program that reads the actual font file and then generates a file that contains a XyWrite width table and font definition. A shareware version is available on Compuserve. A registered version, which works with font files over 40K, is available for $35.00 from the author: John Thompson, 3415 Beechwood Blvd., Pittsburgh, PA 15217. * Run PTEST. PTEST is a XyWrite program that was designed for testing the accuracy of your width tables. You can also use this program to determine the width of each character. For information on this program, refer to Application Note 123, Testing Width Tables in XyWrite III and III Plus. Once you have created the width tables for your new font, compare them to the existing width tables to make sure you have not created a duplicate. CREATE CHARACTER SUBSTITUTION TABLES Character substitution tables are used to translate the character XyWrite sees into codes the LaserJet IID, IIP, and III use to print the character. For example, the substitution table for the line draw character set (SU:PCline in the LaserJet IID/IIP or III printer files) correlates the graphics characters that are part of the extended ASCII character set with the Hewlett-Packard codes necessary to get them to print properly. Each table begins with SU:label where label is the name of the table as defined in a font table. Following the header are the substitutions in the form of character=codes. The printer codes used in the substitution table vary from character set to character set and can be found in the LaserJet documentation or in the instructions that came with your font package. An ET ends the table. The standard XyWrite LaserJet IID/IIP or III printer files contain substitution tables for Roman-8, PC-Line, PC-Symbol, and Legal. You can use these tables without modification if your fonts support any of these sets. Fonts that use the ASCII symbol set do not require a substitution table. If your font uses another symbol set, you must create a character substitution table. Remember to use the same name you used in the US: line of the corresponding font definition table and refer to the documentation supplied with your printer or font for substitution information. LOAD THE PRINTER FILE When all the changes are complete, store and load the printer file. For example, for a printer file named 3HP-NEW.PRN: Type: F5store Type: F5load 3hp-new.prn Result: If the file contains no structural errors, XyWrite displays Done on the prompt line. If a XyWrite formatting error is present, the message on the prompt line is BAD: followed by the offending character(s). Note that successfully loading a printer file does not mean it is error free. Errors in the LaserJet IID/IIP and III escape codes or the wrong values in a width table cannot be detected by XyWrite. If the printed output is not what you expect, check your printer file and correct the errors. TESTING THE PRINTER FILE Whenever you modify a printer file, you should verify your changes by creating a test file and sending it to the printer. Design the test file so that it includes all of the parameters you have just modified. For example, if you defined a new PT table, use that table and all of the modes in your file to be sure you get the expected results; if you changed or added widths, turn on justification so you can verify the right-margin alignment; if you added a character substitution table, type each of the display characters contained in the table to be sure they are translated properly. If your test file does not print successfully, return to the appropriate section of the printer file and make the necessary corrections. Remember, changes to a printer file do not go into effect until you load the printer file into memory. Note #1 DOS Version. If you are using DOS version 3.2 or 3.3 and are connecting the computer to the printer via serial port, then you must put the setting NE=1 on the second line of the printer file. This setting disables all printer errors. Note #2 Memory. To conserve memory, delete any unnecessary information from the printer file. For example, if you do not plan to use XyWrite's redlining feature, you can comment out the insert and delete attributes. To do this, search for the line AT:INSERT and insert a semicolon in front of each of the three lines in that table. Then do the same thing for the table AT:DELETE. (Refer to Application Note 116, Modifying Redlining Modes, for more information.) Note #3 Numbering PT Tables. PT tables do not need to be in numerical order. You might want to set up a numbering scheme in which the first digit of the PT number represents a typeface family and the second two digits represent the point size. For example: PT=109 9-point Helvetica PT=110 10-point Helvetica PT=112 12-point Helvetica PT=209 9-point Times Roman PT=210 10-point Times Roman PT=212 12-point Times Roman ###