How to Download, Select and Remove PCL Fonts

System Requirements

  • A printer with a built-in PCL5 interpreter

  • A host computer that the printer is connect to via Widows share or LPR protocol

PCL stands for Printer Control Language, the language that a host computer used to communicate with the printer. The so-called raw printer data, or printer-friendly data, is expressed in printer control language.

Because communication happens directly between a host computer and a printer, the printer must have a built-in PCL interpreter. Some low-end models use host-based drivers instead (the host-based drivers convert PCL commands into raw printer commands). Those printers do not have the capability of processing PCL commands. Furthermore, the printer must be able to process PCL-5, which supports text and vector graphics data, instead of PCL-3, which only process raster bitmap data (PCL-3 is equipped in HP ink jet printers).

PCL-5 is widely supported by many manufacturers. All HP LaserJet printers support PCL-5. Most Xerox and Lexmark laser printers also fully support PCL-5.

This article assumes that you use PCL commands to download and and remove soft fonts. Some high-end printers provide GUI interfaces to load/unload fonts. Refer to the manufacturer manual for information on how to use the GUI interface to install/remove the fonts.

Downloading PCL Font

The process of transferring PCL fonts from a host computer to the printer RAM is called Downloading. The process involves three steps: (1) assign font ID; (2) copy the font in binary form to the printer RAM; (3) Make the font permanent. The first two steps must happen in one session.

Once downloaded, a PCL font occupies a portion of user memory (RAM). The number of PCL fonts that can be stored in user memory is limited only by the available user memory.

Note: fonts installed in this way reside in printer's RAM area after being madepermanent. However, they cannot survive power outage because RAM is not a persistent storage. Some models allow you to add a hard disk to load the font at start-up. If this is not an option and you need absolute assurance of font existence, we recommend that you design your program in a way that it sends the font at the beginning of every job that requires the font.

In the following illustrations we use <esc> to represent the ESC character. This character is not printable on Windows, but can be inputted using DOS EDIT. Open the text file in EDIT, press key P while holding the CTRL key, and then release both keys. EDIT displays the ESC character using a left arrow followed by an asterisk. In Notepad, this character is displayed as a small left arrow.

Font ID Command

Each soft font downloaded to the printer must have a unique Font ID. This Font ID identifies the font in subsequent commands such as font removal and font selection. The command has the format as:

<esc>*c#D

whereas#is the Font ID assigned.

For example, to specify a Font ID number 80, send

<esc>*c80D

Note

If a font with the same ID exists in the printer, the existing font will be overwritten.

Font Data

The Font Data must immediately follow the Font ID command. These two files can be merged into one and send altogether.

Make Permanent

Once downloaded, a font is designated as temporary. A temporary PCL font is removed from the user memory during a printer reset or a self-test is performed. To prevent the printer from deleting it during a printer reset you need to make it permanent.

The command is

<esc>*c5F

After the three steps are carried out, the font now resides in the printer and can be selected subsequently.

Checking Font Existence

To verify that the font is residing in the printer, you can write some code which selects the font and prints a couple of lines of text. High end printer models usually have a LCD control panel that provides a way to print PCL font list. If a LCD panel is on the printer, you can do the following to print a PCL font list, and check the font name against the list:

  • Press theENTER/MENUkey on the control panel.

  • Use the>or<key to select Reports and pressENTER/MENU.

  • Use the>or<key to selectPCL Font Listand pressENTER/MENU. The printer exits the Menu settings and prints the list.

The image below is taken from the actual print out on a HP LaserJet 2300 model:

Selecting Font

There are two types of font selecting: the first selects the font using its Font ID. The first selects the font by its attributes, such as symbol set, point size and typeface family value. The second type is more appropriate for selecting scalable fonts.

For example, the following statement selects the font with Font ID 80:

<esc>(80X</esc>

The statement below selects scalable font MRV Code39XSA at 16 points:

There are three parts in this statement. The first part, <esc>(0Y selects code 3 of 9 symbol set. The middle part <esc>(s16v sets font size to 16 points. Finally, the last part <esc>(s33221T selects the font with typeface family value 33221 (which corresponds to MRV Code39XSA. Typeface family value is the weakest requirement - however if multiple code 39 fonts are installed in one printer, it can be the only criteria to select the right font.

If MRV Code39XSA is not present in the printer, another code 39 font will be selected. If no code39 fonts are present, the default font is used. Therefore font selection can be used to verify if the font has been properly downloaded to the printer.

To switch back to the default font, using the command:

<esc>(3@

Removing Font

The remove font command takes the following form:

<esc>*c#d2F

Where # is the Font ID of the font to be removed. For example, the following command removes the font we just installed (Font ID 80):

<esc>*c80d2F

Putting Together

In this section we demonstrate downloading fonts with shell commands on Windows and Linux. The commands to use depend on the operating system, as well as how the printer is hooked up to the host computer.

Configuration 1: Peripheral Device

A printer can be connected to a host computer directly as a peripheral device. Under this configuration, this printer can be treated as a file with special names such as LPT1: or /dev/lpt1r. On Windows, a shared printer can be referenced using its share name, such as\\chicago\HPLaserJ(in this case, the printer is connected directly to a computer called chicago and shared through a Windows share name HPLaserJ).

Under this configuration, you can use copy/b on Windows and cat to send file to a printer:

c:\> copy /b C80D.txt +mrvcode39_4pitch.sfp +c5F.txt LPT1:
c:\> copy/b C80D.txt +mrvcode39_4pitch.sfp +c5F.txt  \\Chicago\HPLaserJ 
#cat C80D.txt +mrvcode39_4pitch.sfp +c5F.txt  /dev/lpt1r

Configuration 2: Network Printer Server

When the printer is connected to a TCP/IP network directly, the best method is to send commands throughlpr command. A TCP/IP device may be identified with a full qualified DNS name, or an IP address. In our test lab, we assigned our network printer a fixed IP address 192.168.1.22, and we use this address in the examples below. Inlpr manual page, it is also referred as Printer Name.

Another name you will need is Queue Name. The queue names are names assigned to the processors in the print server. Many print servers and network printers hardcode their queue names. Some allow you to define your own queue. On HP JetDirect printer servers, the raw PCL queues are named as raw, raw1, raw2 and raw3. In this article we use rawas the queue name.

Note thatlpr command only accepts 1 file at a time. However, the step1 and step2 commands must be sent in one stream, otherwise the printer discards them altogether. As a result, you will need to merge those three files into one first. On Windows, you can use copy command:

copy /b C80D.txt +mrvcode39_4pitch.sfp +c5F.txt total.bin

On Linux/Unix platforms, use cat command:

cat c80D.txt mrvcode39_4pitch.sfp c5F.txt > total.bin

Now we can send these files (Windows):

lpr -S 192.168.1.22 -P raw -ol total.bin lpr -S 192.168.1.22 -P raw -ol data.txt

You need to replace the IP address, the queue name and the file name with the appropriate ones in your environment.

On Linux/UNIX platforms, things are more complicated. The configuration varies from platform to platform. Generally you need to set up the printer first. On RedHat Linux, this can be done using printtool. You assign a printer name (queue name) in the configuration, and you use this name in lpr command. Assume that the name is HPPrinter, the lpr command on RH Linux becomes:

lpr -P HPPrinter -o raw total.bin lpr -P HPPrinter -o raw data.txt