Barcode Fonts Explained: Code 39, Code 128 and UPC
A barcode font is a font whose characters are bar patterns, so typing text and applying the font produces a barcode. It works well for Code 39 because the text maps almost directly to the bars. For Code 128 and UPC/EAN, the text has to be encoded first, which is where most barcode font problems come from.
How a barcode font works
Each glyph in the font is a slice of a barcode: a character, or part of one. When you put glyphs side by side, you get a complete symbol. The scanner never knows a font was involved. It just sees bars and spaces.
That means the font has to produce the entire symbol, including parts the user does not normally type: the start pattern, the stop pattern, the check digit and, for EAN, the center guard bars.
Code 39 fonts
Code 39 is the simplest case. You type an asterisk, the data, then another asterisk:
*ABC123*
The asterisks are the start and stop characters. Without them, scanners will not read the barcode. Set the font large and avoid lowercase letters, which are not part of Code 39. Many scanners work without a check digit, so you can skip it unless your system calls for one.
Code 128 fonts
Code 128 is more efficient but its encoding is not a simple mapping. A valid symbol needs:
- a start character that selects subset A, B or C,
- the data characters, which can be switched between subsets mid-symbol,
- a check character calculated from the start value and data,
- a stop character.
Some fonts reassign the check and stop to ordinary-looking characters, so you cannot just type the data. You usually need a macro, an add-in, a formula or a small encoder program that converts your text to the string the font expects. Vendors differ on character mapping, so use the encoder that matches your font.
UPC and EAN fonts
UPC-A and EAN-13 fonts split the number into left and right halves, with different bar patterns for each, plus guard bars. The check digit has to be correct and the encoding tool inserts the guards. If you only need a product barcode or two, a generator is easier than a font. See the UPC generator or the EAN-13 generator.
Common pitfalls
- Missing start or stop characters. A Code 39 barcode without asterisks will not scan.
- No check digit where one is required. Code 128 requires it; UPC and EAN numbers must have a valid last digit.
- Font not installed. If the recipient does not have the font, the cell shows plain text, not a barcode. Embedding the font in the file helps in some programs, but not in all.
- Wrong size. Scale the font so the narrow bars are not blurred. Stretching a font horizontally changes the bar ratio and can break scanning.
- Quiet zone. The blank space around the barcode must stay clear. Do not put a border tight against the bars.
Fonts versus images
| Font | Image (PNG or SVG) | |
|---|---|---|
| Needs install | Yes | No |
| Works across computers | Only if font is present | Yes |
| Updates with cell data | Yes | No |
| Code 128 and EAN support | Needs encoder | Built in |
| Print quality | Depends on font and printer | Crisp at any size with SVG |
Fonts make sense inside a spreadsheet or report template where the data changes constantly and you control every computer. For everything else, images are less work. Barcode Ready's main generator draws any supported symbology in your browser and exports an SVG or PNG; nothing is uploaded. For a long list, the bulk barcode generator does the same for every row.
Checklist
- Pick the symbology your scanner and customer expect.
- For Code 39, add the asterisks. For Code 128 or EAN, use the encoder that comes with the font.
- Install the font on every machine that will print.
- Print at actual size and scan a test label.