-
Notifications
You must be signed in to change notification settings - Fork 309
Differences From BWIPP
For the vast majority of uses, bwip-js and BWIPP behave identically. For example, if you supply the same values in the bwip-js demo and the BWIPP online bar code generator, you will get the same image.
The primary differences are with fonts and background color.
bwip-js uses embedded versions of the OCR-A and OCR-B fonts. Barcodes and the OCR fonts are like chocolate and hazelnut; they were meant to go together. Unfortunately, most PostScript environments do not provide the OCR fonts and must fallback to Courier, Helvetica, and other less-than-ideal typefaces.
The following two images show the differences in typeface. The image below was rendered by bwip-js:
And the next image was rendered using BWIPP with Ghostscript:
The font functionality is implemented with the following logic:
- OCR-B is used as the default font for all barcodes.
- OCR-A is used for the extra text on the ISBN, ISMN and ISSN symbols.
These defaults can be overridden using BWIPP options.
The fonts are known to the PostScript emulation as OCR-A
and OCR-B
.
For example, to switch the font to OCR-A, you would specify the option:
textfont=OCR-A
For the text above the barcode on the ISBN, ISMN, and ISSN symbols, the font
can be changed using isbntextfont
, ismntextfont
, and issntextfont
,
respectively.
A second difference between BWIPP and bwip-js rendering occurs with the
backgroundcolor
option. The BWIPP implementation of background color is a bit
inconsistent. For some bar code types, the background color extends into the
human readable text, and for others, it does not. bwip-js
does not implement BWIPP's background color handling (it is commented out in the PostScript rendering logic).
Instead, the pluggable drawing interfaces override the option and extend
the background color to cover the entire image, including all human readable text.
The first/left image in each pair is from BWIPP using ghostscript, the second from bwip-js.
By default, if the backgroundcolor
option is not specified, bwip-js renders the
image with a transparent background.
All three BWIPP renderers use postscript eval
semantics to convert a color string in either
rrggbb
or ccmmyykk
format to its binary form. Supporting this option required specialized code to be
added to bwip-js. By replacing the evals (and the setanycolor
function bodies) with an internal setcolor
operator, a considerable amount of code was eliminated.
As mentioned above, the backgroundcolor
option was eliminated from the three renderers and replaced with code in the pluggable drawing interface.
renlinear
has been modified to use the OCR-B characters <
and >
as the guard elements for EAN barcodes.
Otherwise, renlinear
and renmatrix
use the original BWIPP rendering logic.
renmaximatrix
is completely custom to bwip-js. It has been replaced by a javascript implementation that is optimized to produce symmetric, aliased (monochrome) hexagons and bullseye rings.