Barcode InfoPCL FontsHome


Cautions concerning barcodes created with TrueType fonts
Home > Barcode Basics >
Application Notes > AppNote009

TrueType fonts provide a quick and convenient means for creating barcodes on Windows-based documents and reports. For example, to print a Code 39 barcode in a word processing document, simply add an asterisk at the beginning and end of the data and use a Code 39 font. Other types of barcodes are a little more complex because they require calculation of a checksum, but the general approach is the same.

While convenient in many applications, TrueType fonts do not provide absolute precision when the barcode is printed; it is almost certain that there will be some variation in the width of the bars. Most types of barcodes encode data by varying the width of the bars, so excessive errors in bar width can make a barcode unreadable.

ideal-actual.gif (481280 bytes)When a TrueType barcode character is printed, Windows converts the physical dimensions of the bars to printer dots and decides which printer dot rows should be turned on or off. In most cases the ideal edge of a bar will not fall precisely on the edge of a printer dot row, and Windows will adjust the edge of the bar to the nearest whole printer dot row. The result is that the edge of a bar could be up to 0.5 printer dot too far to the left or right; in the worst case, the left and right edges would be adjusted in opposite directions, resulting in a maximum possible width error of 1.0 printer dots.

How big this error is depends on the dot-per-inch resolution of the printer and the width of a narrow bar expressed in printer dots. For example, if the width of a narrow bar is supposed to be 0.010 inches (10 mils), it will be 3 dots wide on a 300 dpi printer (0.010 inches x 300 dpi). The rounding error expressed as a percentage would be 0.5 dots (rounding error) divided by 3.0 dots (bar width) or 16.7%. This is a substantial error and it would probably make the barcode unreadable, or at least difficult to read; if both edges of the bar are adjusted in opposite directions, the error could be as large as 33%. On a 600 dpi printer, the error would be cut by half since the same 0.010 inch bar would normally be 6 dots wide, and it would be cut in half again on a 1200 dpi printer. Besides using a higher-resolution printer, another way to reduce the amount of error is to increase the number of dots in a normal bar by making the bars wider.

Some types of codes are more resistant to bar width errors than others. Code 39, for example, provides good results in part because there are only two possible bar widths (wide and narrow), and the maximum allowable wide:narrow ratio of 3.0 makes it relatively easy for a scanner to sort out wides and narrows even if there is a degree of error. Code 128, on the other hand, can be more difficult for a scanner because bars may be any of 4 possible widths. A 4-wide bar is only 33% wider than a 3-wide bar; if there are significant rounding errors, the scanner will have an impossible task. Bar width ratios are fixed in Code 128, so the only options are wider bars and higher-resolution printers.

It is sometimes possible to carefully select a point size that will produce printed bars that fall exactly on printer dot rows. For example, using Code 39 on a 300 dpi printer, we will need to select a narrow bar width and a wide:narrow ratio so that either bar width will divide evenly into 300. Assuming a wide:narrow ratio of 3.0, typical for a low density font, we could use the following sizes. A narrow bar width of 10 dots @ 300 dpi is 33.3 mils, a very generous width. Anything this size or larger is going to reduce the error percentage to a point where it is not likely to be a problem anyway.

Narrow bar Wide Bar
4 dots 12 dots about 5.8 characters/inch
5 dots 15 dots about 4.6 characters/inch
10 dots 30 dots about 2.3 characters/inch

This does not always work to perfection; Windows will sometimes still introduce errors while trying to position or center the characters. Selecting the right font and point size can also be difficult since the point size specifies the height of the character and the resulting bar width depends on choices made by the font designer.

One last caution: The errors that will generally make a barcode unreadable are not the bars themselves but the spaces between them. The spaces carry data, too, and their widths are important. If you have an unreadable barcode, look for a narrow space that has been squeezed down to a barely visible hairline. This happens when the right edge of the bar to the left has been rounded slightly to the right at the same time the left edge of the bar to the right has been rounded slightly to the left. The space in between is squeezed way out of size and the scanner refuses to accept it.

Here are some general guidelines for staying out of trouble:

  • Don't make the barcodes any smaller (narrower) than you have to
  • Use barcode symbologies with only 2 bar widths
  • Use the maximum wide:narrow ratio available (low density instead of high)
  • Use printers with high resolution

TrueType fonts are most suitable for adding barcodes to Windows-generated reports and documents. If you need to print compact barcodes, require a high level of precision, or must consistently meet mandated scanability requirements, you should consider using a different approach.  If you need to create a variety of label designs on a regular basis, consider an interactive label design program; Bar Tender for Windows, for example, provides ease of use and precision.  If your situation is a production operation where you are creating large volumes of similar documents (printing invoices or statements, for example), your business software may already be generating print data using the PCL standard; in this case downloadable PCL Fonts would be a good solution.  PCL barcode fonts are bitmapped and produce precise barcodes with no rounding errors.


(c) Copyright Measurement Equipment Corporation
All Rights Reserved