[comp.lang.postscript] Code 3 of 9 for PostScript

brooks@corpane.UUCP (David E. Brooks Jr) (09/06/90)

Does anyone have any information where I can obtain code to generate barcodes
in 3 of 9 format?  PD, commercial or shareware would be fine.

Thanks,
-- 
David E. Brooks Jr                           UUCP :  ...!ddsw1!corpane!brooks
Corpane Industries Incorporated                      ...!ukma!corpane!brooks
10100 Bluegrass Parkway                      Phone:  +1 502 491 4433 
Louisville, KY  40299                        Quote:  printf("%c", (char) 34)

mleisher@nmsu.edu (Mark Leisher) (09/08/90)

Couldn't get through so here's a small shar file with the 3of9 stuff:

#!/bin/sh
# This is a shell archive (shar 3.24)
# made 09/08/1990 04:04 UTC by mleisher@thrinakia
# Source directory /thrinakia1/mleisher/postscript
#
# existing files WILL be overwritten
#
# This shar contains:
# length  mode       name
# ------ ---------- ------------------------------------------
#   8590 -rw-rw-r-- 3of9/3of9
#   2974 -rw-rw-r-- 3of9/README
#
if touch 2>&1 | fgrep '[-amc]' > /dev/null
 then TOUCH=touch
 else TOUCH=true
fi
# ============= 3of9/3of9 ==============
if test ! -d '3of9'; then
    echo "x - creating directory 3of9"
    mkdir '3of9'
fi
echo "x - extracting 3of9/3of9 (Text)"
sed 's/^X//' << 'SHAR_EOF' > 3of9/3of9 &&
X%!PS-Adobe-2.0
X%
X%  3 of 9 font.  Copyright (C) 1989, John Deters.  All rights reserved.
X%  Permission is hereby granted to freely use this software in any
X%  application, commercial or otherwise, as long as this notice is preserved,
X%  and as long as this portion of the software remains freely redistributable.
X%
X/3of9FontDict 55 dict def
X/workdict 55 dict def 
X% load up drawing procedures
Xworkdict begin
X	/sp1 {
X		1 setgray
X		2 setlinewidth
X		1 0 moveto 1 75 lineto stroke
X		2 0 translate
X	} bind def
X	/sp2 {
X		1 setgray
X		5 setlinewidth
X		2.5 0 moveto 2.5 75 lineto stroke
X		5 0 translate
X	} bind def
X	/mk1 {
X		0 setgray
X		2 setlinewidth
X		1 0 moveto 1 75 lineto stroke
X		2 0 translate
X	} bind def
X	/mk2 {
X		0 setgray
X		5 setlinewidth
X		2.5 0 moveto 2.5 75 lineto stroke
X		5 0 translate
X	} bind def
Xend
X
X3of9FontDict begin
X/FontType 3 def
X/FontMatrix [.01 0 0 .01 0 0] def
X/FontBBox [0 0 10 100] def
X/Encoding 128 array def
X/Widths 128 array def
X
X% Put the proc names of each character in the array 'Encoding'
X0 1 127 {Encoding exch /.notdef put} for
XEncoding (1) 0 get /one put
XEncoding (2) 0 get /two put
XEncoding (3) 0 get /three put
XEncoding (4) 0 get /four put
XEncoding (5) 0 get /five put
XEncoding (6) 0 get /six put
XEncoding (7) 0 get /seven put
XEncoding (8) 0 get /eight put
XEncoding (9) 0 get /nine put
XEncoding (0) 0 get /zero put
XEncoding (A) 0 get /leta put
XEncoding (B) 0 get /letb put
XEncoding (C) 0 get /letc put
XEncoding (D) 0 get /letd put
XEncoding (E) 0 get /lete put
XEncoding (F) 0 get /letf put
XEncoding (G) 0 get /letg put
XEncoding (H) 0 get /leth put
XEncoding (I) 0 get /leti put
XEncoding (J) 0 get /letj put
XEncoding (K) 0 get /letk put
XEncoding (L) 0 get /letl put
XEncoding (M) 0 get /letm put
XEncoding (N) 0 get /letn put
XEncoding (O) 0 get /leto put
XEncoding (P) 0 get /letp put
XEncoding (Q) 0 get /letq put
XEncoding (R) 0 get /letr put
XEncoding (S) 0 get /lets put
XEncoding (T) 0 get /lett put
XEncoding (U) 0 get /letu put
XEncoding (V) 0 get /letv put
XEncoding (W) 0 get /letw put
XEncoding (X) 0 get /letx put
XEncoding (Y) 0 get /lety put
XEncoding (Z) 0 get /letz put
XEncoding (a) 0 get /leta put
XEncoding (b) 0 get /letb put
XEncoding (c) 0 get /letc put
XEncoding (d) 0 get /letd put
XEncoding (e) 0 get /lete put
XEncoding (f) 0 get /letf put
XEncoding (g) 0 get /letg put
XEncoding (h) 0 get /leth put
XEncoding (i) 0 get /leti put
XEncoding (j) 0 get /letj put
XEncoding (k) 0 get /letk put
XEncoding (l) 0 get /letl put
XEncoding (m) 0 get /letm put
XEncoding (n) 0 get /letn put
XEncoding (o) 0 get /leto put
XEncoding (p) 0 get /letp put
XEncoding (q) 0 get /letq put
XEncoding (r) 0 get /letr put
XEncoding (s) 0 get /lets put
XEncoding (t) 0 get /lett put
XEncoding (u) 0 get /letu put
XEncoding (v) 0 get /letv put
XEncoding (w) 0 get /letw put
XEncoding (x) 0 get /letx put
XEncoding (y) 0 get /lety put
XEncoding (z) 0 get /letz put
XEncoding (-) 0 get /dash put
XEncoding (.) 0 get /period put
XEncoding ( ) 0 get /space put
XEncoding (*) 0 get /star put
XEncoding ($) 0 get /dollar put
XEncoding (/) 0 get /slash put
XEncoding (+) 0 get /plus put
XEncoding (%) 0 get /percent put
XEncoding (|) 0 get /bar put
X
XWidths (1) 0 get 29 put
XWidths (2) 0 get 29 put
XWidths (3) 0 get 29 put
XWidths (4) 0 get 29 put
XWidths (5) 0 get 29 put
XWidths (6) 0 get 29 put
XWidths (7) 0 get 29 put
XWidths (8) 0 get 29 put
XWidths (9) 0 get 29 put
XWidths (0) 0 get 29 put
XWidths (A) 0 get 29 put
XWidths (B) 0 get 29 put
XWidths (C) 0 get 29 put
XWidths (D) 0 get 29 put
XWidths (E) 0 get 29 put
XWidths (F) 0 get 29 put
XWidths (G) 0 get 29 put
XWidths (H) 0 get 29 put
XWidths (I) 0 get 29 put
XWidths (J) 0 get 29 put
XWidths (K) 0 get 29 put
XWidths (L) 0 get 29 put
XWidths (M) 0 get 29 put
XWidths (N) 0 get 29 put
XWidths (O) 0 get 29 put
XWidths (P) 0 get 29 put
XWidths (Q) 0 get 29 put
XWidths (R) 0 get 29 put
XWidths (S) 0 get 29 put
XWidths (T) 0 get 29 put
XWidths (U) 0 get 29 put
XWidths (V) 0 get 29 put
XWidths (W) 0 get 29 put
XWidths (X) 0 get 29 put
XWidths (Y) 0 get 29 put
XWidths (Z) 0 get 29 put
XWidths (a) 0 get 29 put
XWidths (b) 0 get 29 put
XWidths (c) 0 get 29 put
XWidths (d) 0 get 29 put
XWidths (e) 0 get 29 put
XWidths (f) 0 get 29 put
XWidths (g) 0 get 29 put
XWidths (h) 0 get 29 put
XWidths (i) 0 get 29 put
XWidths (j) 0 get 29 put
XWidths (k) 0 get 29 put
XWidths (l) 0 get 29 put
XWidths (m) 0 get 29 put
XWidths (n) 0 get 29 put
XWidths (o) 0 get 29 put
XWidths (p) 0 get 29 put
XWidths (q) 0 get 29 put
XWidths (r) 0 get 29 put
XWidths (s) 0 get 29 put
XWidths (t) 0 get 29 put
XWidths (u) 0 get 29 put
XWidths (v) 0 get 29 put
XWidths (w) 0 get 29 put
XWidths (x) 0 get 29 put
XWidths (y) 0 get 29 put
XWidths (z) 0 get 29 put
XWidths (-) 0 get 29 put
XWidths (.) 0 get 29 put
XWidths ( ) 0 get 29 put
XWidths (*) 0 get 29 put
XWidths ($) 0 get 29 put
XWidths (/) 0 get 29 put
XWidths (+) 0 get 29 put
XWidths (%) 0 get 29 put
XWidths (|) 0 get 4 put
X
X% define each letter in bar code
X/CharProcs 55 dict def
XCharProcs /.notdef	{} put
XCharProcs /one		{ mk2 sp1 mk1 sp2 mk1 sp1 mk1 sp1 mk2 sp1 } put
XCharProcs /two		{ mk1 sp1 mk2 sp2 mk1 sp1 mk1 sp1 mk2 sp1 } put
XCharProcs /three	{ mk2 sp1 mk2 sp2 mk1 sp1 mk1 sp1 mk1 sp1 } put
XCharProcs /four		{ mk1 sp1 mk1 sp2 mk2 sp1 mk1 sp1 mk2 sp1 } put
XCharProcs /five		{ mk2 sp1 mk1 sp2 mk2 sp1 mk1 sp1 mk1 sp1 } put
XCharProcs /six		{ mk1 sp1 mk2 sp2 mk2 sp1 mk1 sp1 mk1 sp1 } put
XCharProcs /seven	{ mk1 sp1 mk1 sp2 mk1 sp1 mk2 sp1 mk2 sp1 } put
XCharProcs /eight	{ mk2 sp1 mk1 sp2 mk1 sp1 mk2 sp1 mk1 sp1 } put
XCharProcs /nine		{ mk1 sp1 mk2 sp2 mk1 sp1 mk2 sp1 mk1 sp1 } put
XCharProcs /zero		{ mk1 sp1 mk1 sp2 mk2 sp1 mk2 sp1 mk1 sp1 } put
XCharProcs /leta		{ mk2 sp1 mk1 sp1 mk1 sp2 mk1 sp1 mk2 sp1 } put
XCharProcs /letb		{ mk1 sp1 mk2 sp1 mk1 sp2 mk1 sp1 mk2 sp1 } put
XCharProcs /letc		{ mk2 sp1 mk2 sp1 mk1 sp2 mk1 sp1 mk1 sp1 } put
XCharProcs /letd		{ mk1 sp1 mk1 sp1 mk2 sp2 mk1 sp1 mk2 sp1 } put
XCharProcs /lete		{ mk2 sp1 mk1 sp1 mk2 sp2 mk1 sp1 mk1 sp1 } put
XCharProcs /letf		{ mk1 sp1 mk2 sp1 mk2 sp2 mk1 sp1 mk1 sp1 } put
XCharProcs /letg		{ mk1 sp1 mk1 sp1 mk1 sp2 mk2 sp1 mk2 sp1 } put
XCharProcs /leth		{ mk2 sp1 mk1 sp1 mk1 sp2 mk2 sp1 mk1 sp1 } put
XCharProcs /leti		{ mk1 sp1 mk2 sp1 mk1 sp2 mk2 sp1 mk1 sp1 } put
XCharProcs /letj		{ mk1 sp1 mk1 sp1 mk2 sp2 mk2 sp1 mk1 sp1 } put
XCharProcs /letk		{ mk2 sp1 mk1 sp1 mk1 sp1 mk1 sp2 mk2 sp1 } put
XCharProcs /letl		{ mk1 sp1 mk2 sp1 mk1 sp1 mk1 sp2 mk2 sp1 } put
XCharProcs /letm		{ mk2 sp1 mk2 sp1 mk1 sp1 mk1 sp2 mk1 sp1 } put
XCharProcs /letn		{ mk1 sp1 mk1 sp1 mk2 sp1 mk1 sp2 mk2 sp1 } put
XCharProcs /leto		{ mk2 sp1 mk1 sp1 mk2 sp1 mk1 sp2 mk1 sp1 } put
XCharProcs /letp		{ mk1 sp1 mk2 sp1 mk2 sp1 mk1 sp2 mk1 sp1 } put
XCharProcs /letq		{ mk1 sp1 mk1 sp1 mk1 sp1 mk2 sp2 mk2 sp1 } put
XCharProcs /letr		{ mk2 sp1 mk1 sp1 mk1 sp1 mk2 sp2 mk1 sp1 } put
XCharProcs /lets		{ mk1 sp1 mk2 sp1 mk1 sp1 mk2 sp2 mk1 sp1 } put
XCharProcs /lett		{ mk1 sp1 mk1 sp1 mk2 sp1 mk2 sp2 mk1 sp1 } put
XCharProcs /letu		{ mk2 sp2 mk1 sp1 mk1 sp1 mk1 sp1 mk2 sp1 } put
XCharProcs /letv		{ mk1 sp2 mk2 sp1 mk1 sp1 mk1 sp1 mk2 sp1 } put
XCharProcs /letw		{ mk2 sp2 mk2 sp1 mk1 sp1 mk1 sp1 mk1 sp1 } put
XCharProcs /letx		{ mk1 sp2 mk1 sp1 mk2 sp1 mk1 sp1 mk2 sp1 } put
XCharProcs /lety		{ mk2 sp2 mk1 sp1 mk2 sp1 mk1 sp1 mk1 sp1 } put
XCharProcs /letz		{ mk1 sp2 mk2 sp1 mk2 sp1 mk1 sp1 mk1 sp1 } put
XCharProcs /dash		{ mk1 sp2 mk1 sp1 mk1 sp1 mk2 sp1 mk2 sp1 } put
XCharProcs /period	{ mk2 sp2 mk1 sp1 mk1 sp1 mk2 sp1 mk1 sp1 } put
XCharProcs /space	{ mk1 sp2 mk2 sp1 mk1 sp1 mk2 sp1 mk1 sp1 } put
XCharProcs /star		{ mk1 sp2 mk1 sp1 mk2 sp1 mk2 sp1 mk1 sp1 } put
XCharProcs /dollar	{ mk1 sp2 mk1 sp2 mk1 sp2 mk1 sp1 mk1 sp1 } put
XCharProcs /slash	{ mk1 sp2 mk1 sp2 mk1 sp1 mk1 sp2 mk1 sp1 } put
XCharProcs /plus		{ mk1 sp2 mk1 sp1 mk1 sp2 mk1 sp2 mk1 sp1 } put
XCharProcs /percent	{ mk1 sp1 mk1 sp2 mk1 sp2 mk1 sp2 mk1 sp1 } put
XCharProcs /bar		{ mk1 sp1 } put
X% PostScript will call BuildChar for each character printed in 3of9.
X/BuildChar {
X	workdict begin
X		/char exch def
X		/fontdict exch def
X		/charname fontdict /Encoding get char get def
X		/charproc fontdict /CharProcs get charname get def
X 		/charwidth fontdict /Widths get char get def
X		charwidth 0 setcharwidth
X		gsave
X			charproc
X 		grestore
X	end
X} bind def
Xend
X/3of9 3of9FontDict definefont pop
X%
X% 3of9 is now loaded in the printer and can be used like any other font.
X% Don't forget that you must include the stars at both ends of the text.
X% Also, you must print out the human readable text beneath the bar code,
X% if you wish to conform to MIL-STD-1189A (suppress the asterisks).
X%
X/3of9 findfont 30 scalefont setfont
X72 72 translate
X0 0 moveto
X(*1234567890180100*) show
Xshowpage
SHAR_EOF
$TOUCH -am 0704185690 3of9/3of9 &&
chmod 0664 3of9/3of9 ||
echo "restore of 3of9/3of9 failed"
set `wc -c 3of9/3of9`;Wc_c=$1
if test "$Wc_c" != "8590"; then
	echo original size 8590, current size $Wc_c
fi
# ============= 3of9/README ==============
echo "x - extracting 3of9/README (Text)"
sed 's/^X//' << 'SHAR_EOF' > 3of9/README &&
XThis is a PostScript prolog that will generate a 3 of 9 barcode font.
XI wrote it a few years ago after seeing something similar posted
Xfor UPC codes by Pipeline Associates.  (This is completely different
Xcode, however.)  It allows full ASCII text (lower case is translated
Xinto upper case -- there are no lower case 3 of 9 codes.
X
XAlso enclosed is a small shell script that will wrap your text up
Xin asterisks, append the prolog, and print the barcode on the page.
XIf you want to truly conform to MIL-STD-1189A (4 SEPTEMBER 1984),
XMilitary Standard Department of Defense Bar Code Symbology (SDS), you'll
Xhave to code for it appropriately (my sample doesn't fit all their
Xwonderful dimensions).
X
X  Character density:  9.4 CPI to 3.0 CPI
X  Minimum nominal unit size (thin bar):  .0075 inch
X  Maximum nominal unit size (thin bar):  .0400 inch
X  Nominal wide to narrow ratio:  2.2:1 to 3.0:1 for codes whose
X                                 unit size is less than .015 inch
X                                 2.0:1 to 3.0:1 for codes whose
X                                 unit size is equal to or more than
X                                 .015 inch
X  Minimum bar height:  .25 inch
X  Density range    Minimum height    Maximum height
X  1.7<=CPI<3.0     .75               1.25
X  3.0<=CPI<6.5     .375              .875
X  6.5<=CPI<9.4     .25               .5
X  Intercharacter gap:  The minimum gap is the same as the minimum
X  dimension of a narrow element.  The maximum gap shall be no more
X  than three times the width of a narrow element.
X  Margins (quiet zones):  The minimum left and right margins shall
X  be 10 times the width of one narrow element or .25 inch (whichever
X  is greater).
X  Human-readable interpretation (HRI):  The HRI shall represent only
X  the encoded characters, and start and stop asterisks shall be
X  suppressed.  It is not intended to be machine readable.  The HRI
X  is to be printed in an easily readable font, and are to be a
X  minimum of .094 inch in height.  The HRI shall be printed above
X  or preferably below the bar code.
X  Spacing between bar code and HRI:  Minimum of .1 inch, max of .25 inch.
X  Spacing between edge of label and HRI:  Minimum .0625 inch
X  Spacing between SDS messages (vertical):  Min .375 inch, max .75 inch.
X  Spacing between SDS messages (horiz.):  Min .5 inch
X  Maximum number of encoded characters:  30 data, 32 including start and
X  stop characters, and other control characters that may be used.
X
XThere is a bunch of other stuff in this MIL-SPEC pertaining to opacity,
Xreflectivity, tolerances, and spots and voids that probably won't
Xaffect anyone using a 300dpi printer with black ink.
X
XDISCLAIMER:  I am not responsible.  Just ask my boss.  This code is
Xprovided AS IS, and I make no warranties about its fitness for a
Xparticular purpose.  If you use this code and it doesn't work for you,
Xtough.  I can't be held responsible for any damages for your using this
Xcode.  How's that for a nasty thing to have to say?
SHAR_EOF
$TOUCH -am 0704185590 3of9/README &&
chmod 0664 3of9/README ||
echo "restore of 3of9/README failed"
set `wc -c 3of9/README`;Wc_c=$1
if test "$Wc_c" != "2974"; then
	echo original size 2974, current size $Wc_c
fi
exit 0
--
-----------------------------------------------------------------------------
mleisher@nmsu.edu                      "I laughed.
Mark Leisher                                I cried.
Computing Research Lab                          I fell down.
New Mexico State University                        It changed my life."
Las Cruces, NM                     - Rich [Cowboy Feng's Space Bar and Grille]