A date code, batch number or serial string fails on the line for one of two reasons: the font gives the classifier nothing to hold on to, or the optics deliver too few pixels per character. This guide is for the person who writes the label specification and the one who has to read it afterwards. You get the font qualities OCR and OCV tools reward, the acceptance numbers behind them, a worked example that turns character height into a pixel budget, and the checks to run before the artwork is frozen.
The decision: which fonts a machine reads reliably
A machine reads a single-stroke, fixed-pitch sans-serif or a dedicated machine font most reliably. When only the machine reads the string, OCR-A is the strongest choice. When people read it too, OCR-B keeps nearly all of the machine margin while looking normal. When branding rules out machine fonts, a plain fixed-pitch sans-serif — road-sign lettering rather than book type — keeps most of the margin, and every step away from it (serifs, thin-and-thick strokes, tight kerning, decorative forms) costs pixels, light or both.
Trainable OCR tools change nothing here. They learn any character set you show them, so no font counts as unsupported — but training only maps the margin that contrast, stroke width, spacing and pixels create. A decorative face can be trained and still fail on day two, when ink spread pushes the print just past what the template tolerates. Font choice decides how much margin you start with; the qualities below decide where the rest comes from.
What OCR and OCV need from a character
OCR splits a string into characters, then classifies each one; OCV compares each character against a reference and grades the difference. Both fail the same way: characters merge, strokes break or fill in, and shapes that were distinct in training arrive as their neighbours. The qualities that prevent it:
- Uniform stroke width. Keep the stroke within about 10% of nominal across each character. Most OCV scoring rejects prints beyond roughly that limit, and thin-and-thick typographic contrast defeats a segmentation threshold, because no single threshold holds both a hairline and a bold stem.
- Continuous contours with hard edges. Classifiers want unbroken shapes. Dot-matrix print is a chain of cells that breaks every contour; it reads, but on a reduced margin (see below).
- Fixed pitch with generous gaps. Keep at least one stroke width of clear space between characters. Proportional spacing and kerning close the gap unevenly, and two touching characters segment as one blob no matter how well each was trained.
- Open, distinct glyphs. Open apertures and exaggerated differences keep confusable pairs — O against 0, I against 1, S against 5, B against 8 — separable after blur and ink gain.
- No serifs, no decoration. A serif is a blob at the end of a stroke that grows and shrinks with ink pressure; hairlines sample badly.
- Strong matte contrast. Plan on at least 100 of 255 gray levels between ink and background. Matte black on white paper delivers twice that and leaves the threshold far from both populations.
- Quiet margins. Keep borders, logos and neighbouring text at least one character height away from the string, or segmentation will walk into them.
Machine fonts: OCR-A and OCR-B
OCR-A was built for machines first: simple, thick, uniform strokes and exaggerated character forms that a person finds mechanical to read — see the OCR-A typeface. OCR-B followed as a standard face that people read comfortably and machines still score well, with the same uniform stroke widths and none of the decoration. Both are standardized in ISO 1073, so an OCR-B label from your printer next year behaves like this year's.
Use OCR-A when nothing downstream reads the string by eye. Use OCR-B everywhere else — it is the default answer for serial and date strings that operators also check.
One practical trap: OCR font files come in several formats, and reading and verification software each expect a specific one. If an import fails with an unrecognized-file-format error, the typeface is usually fine and the file format is not — this OCR font file format error walkthrough shows the case and the fix.
Dot-matrix and branded fonts you cannot choose
Continuous inkjet prints in dots, not strokes. Train on production samples of the actual dot font, and when characters still drop out, diagnosing missing OCR characters lists the filtering causes in order. Two adjustments recover most of the margin:
- Budget roughly 30 pixels of character height instead of 20. A stroke made of cells has gaps and twice the edges, so each cell needs its own sampling.
- Light for dot-to-background contrast and keep the cells fully formed; ink pressure, standoff and substrate all change dot size. The dome, dark field or backlight choice for inkjet OCV covers the lighting side.
A brand typeface — serif, proportional, decorated — is a business decision, not a vision one. Keep it and buy the margin back in pixels: a hairline serif stroke can sit under a tenth of the character height, so holding 4 pixels on it takes about 40 pixels of height, twice the sans-serif budget. Add tight lighting control, and where the print wraps a curve — a bottle neck, a cap top — plan to train a custom font on samples from the curved surface rather than on flat proofs.
Worked example: pixels per character for 2.5 mm date-code text at 150 mm
The inputs, each with its source:
- Character height 2.5 mm — the label specification; a typical continuous-inkjet date-code size.
- Pixel budget 20 pixels per character — the sampling rule above, which holds about 4 pixels across a stroke at the usual one-fifth-of-height stroke weight.
- Working distance 150 mm — what the mount gives you from lens to print.
- Reader: 2560 x 2048 pixels, 8 mm lens, 1/1.7-inch sensor — the catalog values for the reader below. A 2560 x 2048 array is a 5:4 format, and a 1/1.7-inch type runs about 9.4 mm across the diagonal by the usual 16 mm per inch-type convention, which puts the sensor about 5.9 mm tall.
The rule in words: pixels per character equals character height divided by pixel scale; pixel scale is the field of view height divided by the pixels along that edge; and the field of view height is roughly sensor height times working distance, divided by focal length.
46 pixels is 2.3 times the 20-pixel budget: the stroke lands about 9 pixels wide, with room for ink spread, skew and slight defocus. Run the rule backwards for the limit. At 0.125 mm per pixel the budget is spent, so the field of view can grow to 0.125 mm per pixel × 2048 px = 256 mm, which is a working distance of 256 mm × 8 / 5.9 ≈ 350 mm with this lens. The formula ignores lens extension; at this magnification, about 0.05, the exact figure sits near 49 pixels per character, so the approximation is slightly conservative.
Decision: at 150 mm the setup reads the 2.5 mm string with margin; keep the mount inside about 350 mm, and add pixels before you add distance. Run your own character height and stand-off through the same arithmetic:
One 5 MP global-shutter code reader that carries this budget:
- Interface
- Fast Ethernet
- Resolution
- 5 MP
- Sensor format
- 1/1.7"
- Shutter
- Global
Matching the reader to the string
Work backwards from the smallest string on the part:
- Tight space, larger characters. A compact reader with fewer pixels does the job and keeps decode times short; the fixed code readers page filters by resolution, mount and interface. The MV-ID3013PM-12M-WBN carries a 12 mm focal length lens on a 1.3 MP sensor with a global shutter and an M12 mount.
- Small characters or a longer stand-off. Pixels per millimetre scale with the sensor count, so a 12 MP reader delivers about 1.55 times more (√(12/5) ≈ 1.55) than a 5 MP one and moves the 20-pixel limit from roughly 350 mm to about 540 mm at the same focal length. The MV-ID5120RM-08M-RBN carries 12 MP over GigE with a rolling shutter and an M12 mount — a rolling shutter suits a part that stops for the read; choose a global shutter when text moves during exposure.
- OCR plus presence or defect checks on one device. A smart camera handles it: the MV-SC5060XM-08M-WBN pairs a 6 MP mono sensor with an 8 mm focal length lens in an M12 mount, and mono keeps character edges free of color-filter smoothing.
Then narrow the ROI around the string; setting an ROI for inline code reading shows how much decode time that recovers on its own.
The two readers above bracket the range from tight mounts to longer stand-offs:
- Interface
- Fast Ethernet
- Resolution
- Up to 3 MP
- Interface
- GigE
- Resolution
- 12 MP
When the usual answer is wrong
Three cases where the machine-font advice does not apply:
- Symbology-controlled text. The human-readable digits under an EAN-13 barcode belong to the symbol specification, so keep them as the standard draws them; the EAN-13 human-readable layout and its light margin indicator shows what is fixed and what is free.
- Displays instead of print. A seven-segment readout offers no font choice at all, and its failure mode is the missing segment; the seven-segment OCR approach handles that with region limits and segment logic rather than font quality.
- Brand-critical packaging. Replacing the brand face with OCR-B can cost more than pixels would. Keep the brand font and pay with a shorter working distance, more resolution and controlled light — the worked example above is the exchange rate.
Checks before you freeze the label spec
Run these on production stock, not office paper:
- Print 20 samples that span normal drift: fastest and slowest line speed, fresh and tired ink.
- Measure stroke width and character gaps; hold stroke within about 10% of nominal and gaps at or above one stroke width.
- Compute pixels per character at the real working distance: 20 for a mono sans-serif or machine font, 30 for dot-matrix, 40 for serif hairlines.
- Train the OCR or OCV tool on those samples, not on a reference font file.
- Grade a batch with OCV scoring and set reject limits before release; grading a date-code string walks the scoring.
- Re-run the worst case last: lowest-contrast substrate, maximum skew, fastest belt.
If you share the character height, working distance and line speed, we will shortlist readers that hold the budget; the camera finder filters by resolution, shutter and interface, and the code-reading guides cover the rest of the chain. Size the station from the camera step:
The configurator matches a camera, lens, light, light controller and cables to each other, step by step, and lists only parts that fit what you already picked.
Questions
What is the best font for machine OCR?
OCR-A when only the machine reads the string, OCR-B when people read it too. Both are standardized machine fonts with uniform stroke widths and exaggerated character forms, so they train cleanly and survive process drift. A plain fixed-pitch sans-serif is the next best; decorative serif or script faces work only with a much larger pixel budget and controlled lighting.
How many pixels does a character need for reliable OCR?
Plan on at least 20 pixels of character height at the sensor, which is about 4 pixels across a typical stroke. Check any setup quickly: divide the character height in millimeters by the pixel scale (field of view height divided by the pixels along that edge) and compare the result with 20. Dot-matrix print wants roughly 30, serif hairlines 40.
Can OCR read dot-matrix inkjet characters?
Yes. Train on production samples of the actual dot font, never on a clean reference face, and budget about 30 pixels of character height because the stroke is a chain of cells with broken contours. Keep the cells fully formed and light for maximum dot-to-background contrast. Retrain whenever the printer, ink or substrate changes.
What character spacing should a label specification require?
Fixed pitch with a clear gap of at least one stroke width between characters. The gap has to survive process drift: a print that wanders 0.2 mm across the label closes a 0.15 mm design gap, and characters that touch get cut as one region and both fail. Avoid proportional spacing and kerning entirely.
Does ink color matter when a mono camera reads text?
Only as grayscale contrast. A mono camera sees each ink according to its spectral response, so red print under white light can wash out toward the background while the same print reads dark under red illumination. Pick ink and light wavelength so the ink stays dark where the sensor is sensitive and the background stays bright.
If the OCR tool is trainable, does font choice still matter?
Yes. Training maps whatever contrast, spacing and pixels you deliver; it cannot create them. A face with touching characters or hairline strokes can be trained and still fail on production drift, because the print moves outside what the template tolerates. Font quality sets the starting margin, and training on real production samples holds it.


