Debian Codegraph @

texmf-dist/source/latex/barcodes/barcodes.dtx

raw
1 % \iffalse meta-comment
2 %
3 % This is part of the barcode package.
4 % You should run
5 % tex barcodes.ins
6 % instead of reading/running this file.
7 % Among other things, you will then get a documentation.
8 % I guess you need some, or you wouldn't look here.
9 % \fi
10 %
11 %% \CharacterTable
12 %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
13 %% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
14 %% Digits \0\1\2\3\4\5\6\7\8\9
15 %% Exclamation \! Double quote \" Hash (number) \#
16 %% Dollar \$ Percent \% Ampersand \&
17 %% Acute accent \' Left paren \( Right paren \)
18 %% Asterisk \* Plus \+ Comma \,
19 %% Minus \- Point \. Solidus \/
20 %% Colon \: Semicolon \; Less than \<
21 %% Equals \= Greater than \> Question mark \?
22 %% Commercial at \@ Left bracket \[ Backslash \\
23 %% Right bracket \] Circumflex \^ Underscore \_
24 %% Grave accent \` Left brace \{ Vertical bar \|
25 %% Right brace \} Tilde \~}
26 %%
27 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
28 % % EAN documentation starts here %%
29 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
30 %<*eandoc>
31 \documentclass{article}
32 \begin{document}
33 \author{Peter Willadt}
34 \title{EAN Barcodes by \TeX{} an Metafont}
35 \date{1998-01-24}
36 \maketitle
37 \begin{abstract}
38 This article documents the use of the font {\tt wlean.mf}. With the font,
39 there also comes an auxiliary Perl file for preprocessing TeX source.
40 Its use is also documented here.
41 \end{abstract}
42
43 \section{Legal Restrictions and Introduction}
44
45 All the files in this package are subject to the \LaTeX\ Project Public
46 License. Also I got a special wish: If you find this package useful,
47 support TUG or your local \TeX\ user group.
48
49 The complete contents of this package is
50 described in the file {\tt README}. That file also contains some
51 information about the use of the other barcode fonts that are
52 contained. For more information about these other files you may want
53 to read an article that has appeared in the december, 1997 issue of
54 {\em TUGboat}. Please see also the remarks in the section {\em
55 Address} later in this file.
56
57 \section{About {\sc ean}}
58
59 In stores, {\sc upc} and {\sc ean} codes are widely used for automatic
60 identification, pricing etc. {\sc ean} consist of either eight or
61 thirteen digits. Twelve digit {\sc upc} codes are like thirteen digit
62 {\sc ean} with the first digit equal to zero. {\sc ean} specifications
63 do not only
64 require bars, also the encoded number has to be written in plain text,
65 in case a reader is defective or the code is too hard to read. {\sc
66 ean} is a high-density code, and so it is highly vulnerable.
67
68 \subsection{Coding}
69
70 The last digit of an {\sc ean} is a weighted mod 10 checksum. Digits
71 are alternatingly multiplied by 1 or 3. The so calculated sum over all
72 digits has to be divisible by ten without any remainder.
73
74 There are three different {\sc ean} character sets labeled A, B, and
75 C. Eight digit {\sc ean} codes use character sets A and C, {\sc ean}
76 codes with thirteen digits use all three character sets---see below.
77
78 \begin{verse}
79 {\sc ean} with eight digits consists of:\\
80 a sidebar\\
81 the first four digits (coded in character set A),\\
82 the middle separator,\\
83 the other four digits (coded in character set C)\\
84 another sidebar.
85 \end{verse}
86
87 The first half of an {\sc ean} code with thirteen digits is coded in
88 the character sets A and B, the second half in character set C. The
89 coding of the very first digit is hidden in the varying use of the
90 character sets A and B. A C programmer might use the following table
91 and algorithm to decide which character set to use for digits 2--7:
92
93 \begin{verbatim}
94 static UBYTE abtab[10][6]={
95 {0,0,0,0,0,0}, /* 0 */
96 {0,0,1,0,1,1}, /* 1 */
97 {0,0,1,1,0,1}, /* 2 */
98 {0,0,1,1,1,0}, /* 3 */
99 {0,1,0,0,1,1}, /* 4 */
100 {0,1,1,0,0,1}, /* 5 */
101 {0,1,1,1,0,0}, /* 6 */
102 {0,1,0,1,0,1}, /* 7 */
103 {0,1,0,1,1,0}, /* 8 */
104 {0,1,1,0,1,0} /* 9 */
105 };
106
107 char eancode[18];
108 char eansource[14]="4025700001030";
109
110 eancode[0]=eansource[0];
111 eancode[1]=' ';
112 eancode[2]='+';
113 for(i=1;i<7;i++)
114 eancode[i+2]='A'+eansource[i]-'0'
115 +abtab[eansource[0]-'0'][i-1]*('a'-'A');
116 /* then the middle separator, digits 7--13,
117 * and the final + sign */
118 \end{verbatim}
119
120
121 A zero means to use character set A and a one means to use character
122 set B for the respective digit. The printed code of an {\sc ean} 13
123 consist of the following elements, from left to right:
124
125 \begin{verse}
126 The first digit in human-readable form\\
127 an {\sc ean} sidebar\\
128 six digits in character sets A or B\\
129 the {\sc ean} middle separator\\
130 six digits in character set C\\
131 another {\sc ean} sidebar
132 \end{verse}
133
134 Magazines or codes with pricing have a so called extension following
135 the main code with some fixed distance. This extension consists of one
136 sidebar and two or five digits. As I have no full {\sc ean}
137 documentation at hand at the time of this writing, I am sorry that I
138 am not able to tell you more about this.
139
140 The {\sc ean} digits themselves obey to the following rules: Each
141 digit takes seven units of space. Some of the seven elements are
142 white, others are black. Digits from character set A always are white
143 at the left edge and black at the right, and they always have an odd numer
144 of black elements. Digits from character set B are quit similiar, but
145 they have an even number of black elements. Digits from Character set C
146 always start with a black element and have an even number of
147 black elements. The rightmost element in character set C is always white.
148 The sidebars are three elements wide, the middle separator takes five
149 elements.
150
151 \subsection{What {\sc ean} numbers may I use?}
152
153 For inhouse use, you may use any 13-digit {\sc ean} that starts with a
154 2. If you want to have your products sold elsewhere, you have to buy a
155 set of {\sc ean} numbers from the organisation in your country that
156 holds these numbers. For germany, this organisation is the {\em
157 Zentrale f\"ur Coorganisation} in Cologne. Almost any country has a
158 similiar organisation.
159
160 The first digit or sometimes the first two digits code the country of
161 origin, the next five to six digits code the manufacturer, the eigth
162 to twelfth digits are for free use by the manufacturer. The
163 thirteenth digit is, as explained above, a checksum. {\sc ean} do not
164 contain any qualifiers, so if you get an {\sc ean} from somewhere, you
165 may find out about the country of origin and about the manufacturer of
166 the product, but if you want to know more, you have to contact the
167 manufacturer.
168
169 \section{Using {\tt wlean.mf}}
170
171 {\tt wlean.mf} is rather raw. It contains all three {\sc ean}
172 character sets within one single font, but at different places.
173 The character sets A, B, C, and the digits are
174 featured through the following characters:
175
176 \begin{verse}
177 0 to 9 yield the digits from 0 to 9\\
178 A to J yield the codes from character set A\\
179 a to j yield the codes from character set B\\
180 K to T yield the codes from character set C\\
181 + makes the left and right sidebar and\\
182 - makes the middle sign
183 \end{verse}
184
185 So, to code the number {\tt 2099993098253}, you have to write\\
186 \verb*|{\eanfont2 +AJjjJd-KTSMPN+}|. The space is necessary to separate
187 the leading 2 from the barcode.
188
189 {\tt wlean.mf} does not use true {\sc ocr} digits, as it should. As
190 the digits will not be used for {\sc ocr}, I do not consider this as
191 a serious restriction. If you really need {\sc ocr} digits, there is
192 an {\sc ocr} font on {\sc ctan}. And in {\em TUGboat}, there has been
193 a publication about {\sc ean}, where \TeX{} draws the bars and
194 the {\sc ocr} font prints the digits, see [1].
195
196 {\tt wlean.mf} uses the normal {\sc ean} dimensions. If you would like
197 lower bars---in contradiction to the {\sc ean} rules---you have to edit
198 the source. The rules also make recommendations about the scaling. To
199 be fully compatible, this font may be scaled 0.8, 0.9, 1, 1.2, 1.4,
200 1.5, 1.7, 1.85, or 2 times the original size. With a 300 dpi printer,
201 I do not recommend using sizes$<1.0$.
202
203 \subsection{Installation}
204
205 The installation itself is pretty mundane, like with any plain font.
206 Just copy {\tt wlean.mf} to a location where Metafont can find
207 it. Then invoke Metafont to create a {\sc tfm} file. Move this {\sc
208 tfm} file where \TeX{} can find it. Type in the example at the end of
209 this file and run it through \TeX{}. Then call Metafont again to
210 produce a font suitable for your printer or previewer and move this
211 font to an appropriate location. You may also want to edit {\tt
212 codean.pl} to run on your shell. For this purpose you have to read
213 your system's documentation or the documentation that comes with Perl.
214
215 \subsection{Making readable output}
216
217 Don't make {\sc ean} too small. With a 300 dpi printer, you should not
218 use this font with magnification$<1$; {\tt scaled 1200} will be okay.
219 If you want to do mass production, go to somebody with a barcode
220 reader and check your output, {\em before} you loose money. You also
221 should consider changes in the blackness that may be caused by
222 production printing devices. And, of course, you should only use
223 colours that can be used with barcode reading devices. Especially, do
224 not use red and watch for much contrast between the colour you print
225 and the colour of the paper.
226
227 \subsection{Coding the numbers}
228
229 You will perhaps not want to write something as ugly and error-prone
230 as \verb*|{\eanfont2 +AJjjJd-KTSMPN+}| manually. So you have to use a
231 preprocessor\footnote{See bcfaq.tex for \TeX{} code to go without
232 preprocessing. It is very fine.}. With {\tt wlean.mf} there comes a
233 tiny Perl program ({\tt codean.pl}) that does preprocessing within
234 your \TeX{} sources\footnote{codean.pl in the meantime also handles
235 code 128. See bcfaq.tex}.
236
237 The \TeX{} file to be filtered may contain any number of lines
238 that have one of the following commands starting at the leftmost position.
239
240 \begin{itemize}
241 \item \verb|\ean{|{\em12 or 13 digit number}\verb|}|
242 The number will be coded as {\sc ean}. If it is only 12 digits long, the
243 checksum will be calculated, too.
244
245 \item \verb|\embed{|{\em12 or 13 digit number}\verb|}|
246 The number is used as a base for embedding article numbers \&c.\
247 within an {\sc ean}.
248
249 \item \verb|\eean{|{\em number with at most 11 digits}\verb|}|
250 This number is to be embedded within an {\sc ean}.
251
252 \item \verb|\isbn{|{\em valid ISBN}\verb|}| An {\sc isbn} to
253 make an embedded {\sc ean} of.
254 \end{itemize}
255
256 Let's look at an example: You want the {\sc isbn} {\tt0-201-13448-9}
257 to be embedded. So you write \verb|\isbn{0201134489}|, but you might
258 also use the embedding method and write
259 \verb|\embed{9780000000000}| and, somewhere later in the file,
260 \verb|\eean{020113448}|. In this latter case you have to omit the last digit,
261 as {\sc isbn} loose their check digit in favour of the {\sc ean} check digit.
262 Anyway you do it, you get your command replaced by
263 \verb|\EAN{|{\em13-digit-number-coded-strange}\verb|}| in the output
264 file.
265
266 But embedding is especially useful if you also write the program that
267 reads the barcodes. This program might then extract your article
268 number from an {\sc ean} starting with {\tt20}, eg.
269
270 What you have to do is, of course, to use stub definitions for the
271 three macros mentioned above---as they shall never actually be
272 typeset---and to use a valid definition for \verb|\EAN|. Then you run
273 your \TeX{} source through {\tt codean.pl}. This program takes as
274 first parameter the name of your original file and as second parameter
275 the name of your destination file. If you omit the parameters, you will
276 be asked for them.
277
278 You may of course also peek the source of {\tt codean.pl} to see how
279 {\sc ean} checksums are calculated, and so on.
280
281 \subsection{Example}
282
283 Here is a full example.
284 Use this \TeX{} source:
285
286 \begin{verbatim}
287 \font\eanfont=WLEAN
288 \def\ean#1{\message{Call codean.pl}}
289 \def\eean#1{\message{Call codean.pl}}
290 \def\isbn#1{\message{Call codean.pl}}
291 \def\embed#1{}
292 \def\EAN#1{\vbox{\vskip10pt\eanfont#1\vskip10pt}}
293 Now, something to do:
294 \ean{4025700001030} % or, without checksum:
295 \ean{402570000103}
296 \embed{2500000000000}
297 \eean{123}
298 \isbn{0201134489}
299 \end{verbatim}
300
301
302
303 Having run your file through {\tt codean.pl}, the lines after the percent
304 sign look like this:
305
306 \begin{verbatim}
307 Now, something to do:
308 \EAN{4 +AcFHaa-KKLKNK+} % or, without checksum: %(4025700001030)
309 \EAN{4 +AcFHaa-KKLKNK+} %(402570000103)
310 \embed{2500000000000}
311 \EAN{2 +FAaaAa-KKLMNT+} % embedded(123)
312 \EAN{9 +HiaCaB-LNOOSN+} % ISBN(0201134489)
313 \end{verbatim}
314
315
316 Running this file through \TeX{}, you get {\sc dvi} output containig
317 {\sc ean} barcodes. Perhaps you wonder why there is not even a
318 single {\sc ean} contained within this documentation. The reason is
319 quite simple: You should be able to read the docs {\em before} you
320 have installed the font. But now is the right time to try the example
321 on your own. Better yet, you may code an {\sc ean} where you have
322 taken the number from something like your favourite candy and then,
323 having printed it, you may compare the bars. This is a nice way to
324 spend your evenings. I actually started deciphering {\sc ean} codes in
325 this way, several years ago.
326
327 \section{The End}
328
329 \subsection{Address}
330
331 Just in case you want to write to me, here is my address---but
332 please note: I am not the {\sc ean} guru.
333
334 \begin{verbatim}
335 Peter Willadt
336 75177 Pforzheim
337 Germany
338 email: [email protected]
339 \end{verbatim}
340
341 I also would appreciate if only one version of the material contained
342 in this package is distributed. So if you have any corrections,
343 suggestions, \&c., please do not hesitate to send them to me to
344 incorporate them within this package.
345
346 \subsection{Acknowledgement}
347
348 I want to express my special thanks to Barbara Beeton for proofreading
349 and making valuable suggestions. If there are still any typos or
350 illegibilities, that is due to the fact that I had to change some
351 things later on.
352
353 \begin{thebibliography}{1}
354
355 \bibitem{bc:ean}
356 Peter Ol{\v{s}}ak.
357 \newblock The {\sc ean} barcodes by {\TeX}.
358 \newblock {\em TUGboat}, 15(4):459--464, 1994.
359
360 \end{thebibliography}
361
362 \end{document}
363 %</eandoc>
364 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
365 % % EAN documentation ends here %%
366 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
367 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
368 % % general documentation starts here %%
369 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
370 %<*bcfaq>
371 % this file contains answers to frequently asked questions (FAQ)
372 % about barcodes and---to some extent---VPL files.
373 \documentclass[a4paper]{article}
374 \bibliographystyle{alpha}
375
376 % macros for the examples
377 % These are documented within the text.
378
379 % Barcode fonts
380 \font\itf=wlitf scaled 1200
381
382 % barcodes with depth
383 \def\bcbox#1{\lower3pt\hbox{\itf +#1-}}
384
385 % barcodes made taller
386 \newbox\bsavebox
387 \newdimen\bcboxdepth
388 \bcboxdepth=4pt
389 \def\bdbox#1{\setbox\bsavebox\hbox{\itf +#1-}
390 \vbox{\hsize=\wd\bsavebox\offinterlineskip%
391 \copy\bsavebox%
392 \vskip-\ht\bsavebox\vskip\bcboxdepth%
393 \box\bsavebox\vskip-\bcboxdepth}}
394 \def\bebox#1{\setbox\bsavebox\hbox{\itf +#1-}
395 \vbox{\hsize=\wd\bsavebox\offinterlineskip%
396 \copy\bsavebox%
397 \copy\bsavebox%
398 \vskip-\ht\bsavebox\vskip\bcboxdepth%
399 \box\bsavebox\vskip-\bcboxdepth}}
400
401 \def\tbs{{\tt\char92}}
402 % makes a typewriter backslash
403 \begin{document}
404 \title{Barcodes-FAQ}
405 \author{Peter Willadt}
406 \date{2003-05-24}
407 \maketitle
408 \begin{abstract}
409
410 This file deals with questions about barcode fonts created for
411 \TeX{}. Its purpose is not to replace the regular documents, but to add
412 informations that may be of no interest for the casual reader.
413
414 \end{abstract}
415
416 \section{Changelog}
417
418 \subsection{Changes of the barcode package in general}
419 \begin{tabular}{ll}
420 \em Date & \em Change\\
421 2003-05-24 & new release with some corrections to codean.pl\\
422 & Thanks to Jacek Ruzycka (uv\[email protected])\\
423 1999-05-29 & added license note to README\\
424 1999-05-29 & added install.bat\\
425 1998-11-28 & included wlcr39, wlcf39, and wlc93\\
426 1998-04-21 & fixed wlitf bug\\
427 1998-04-10 & switched partially to docstrip archive\\
428 & added support for code 11\\
429 1998-01-24 & added code 128 in MF format, changed codean.pl\\
430 1997-11-08 & changed metrics of {\sc itf} start/stop chars\\
431 1997-10-09 & released first version of the barcode package
432 \end{tabular}
433
434 \subsection{Changes within this document}
435
436 \begin{tabular}{ll}
437 \em Date & \em Change\\
438 1999-05-29 & added short info about install.bat\\
439 1998-11-28 & added docs about code 93\\
440 1998-04-10 & added docs about code 11\\
441 1998-01-24 & added information about code 128\\
442 1997-12-08 & added contributions to {\sc ean} coding by Kalvis M. Jansons\\
443 & changed section on plessey\\
444 1997-11-09 & added several items, rearranged sections\\
445 1997-11-08 & started writing first version
446 \end{tabular}
447
448 \section{Introduction}
449
450 The barcode package itself can be found on {\tt ctan} in the
451 subdirectory\\ {\tt fonts/barcodes/willadt}. It contains---among
452 others---several fonts in {\sc vpl} format, so your {\sc dvi} driver
453 should be able to handle virtual fonts. If it doesn't, you may perhaps
454 use {\em dvicopy} to resolve the references to virtual fonts, or you
455 may perhaps upgrade to a more modern \TeX{} package.
456
457 \section{What about docs?}
458
459 \subsection{Docs about barcodes}
460
461 With the barcode package, there comes documentation about {\sc ean}
462 fonts. In the README file, there are short examples of the use of
463 the other fonts, too. Also the files {\tt examples.tex} shows the look
464 and basic usage of the barcodes.
465
466 In {\sl TUGboat}, barcoding has been covered in several
467 articles \cite{bc:ean,bc:sauter,bc:vulis}. The barcode package itself
468 is covered in an article that has appeared in the december issue,
469 1997, of {\sl TUGboat}. As TUGboat is making the elder articles available
470 online, I recommend looking for it.
471
472 \subsection{Some information about code 128}
473
474 Code 128 is able to print all 128 ascii chars. There are a little more
475 than a hundred glyphs that are interpreted in three different
476 ways. Some of the glyphs are used as shift chars to determine which
477 interpretation to use. A checksum is mandatory. To use it, you must
478 install {\tt wlc128.mf}.
479
480 The preprocessing---switching among the different character sets,
481 coding efficiently, calculating the checksum---is handled by the
482 newer versions of codean.pl. This is perhaps not as pleasing as to do
483 it with \TeX{} alone, but, alas, it works.
484
485 The way to run the preprocessor is described in {\tt eandoc.tex}. To
486 use code 128, you have to write a line starting with {\tt\tbs cxxviii\{}
487 followed by the characters you want to code and followed by a closing
488 brace. Non-printing seven-bit ascii characters may be specified in hex
489 in C or \TeX{} style, like {\tt\tbs x3f} or \verb|^^3f|. Anything up to
490 the rightmost closing brace in this line will be coded---there is no
491 brace matching. But you will get a warning message if your text
492 includes a right brace. So you may want to code braces in hex form to
493 avoid this message. Please note that {\tt codean.pl} does almost no
494 checking for errors, so if you intend to produce garbage, there are
495 lots of ways. If you need code 128 escape characters, they may be
496 included as hex characters with codes starting at 0x80.
497
498 \begin{tabular}{lllll}
499 \em Input Code & \em C128 number &\multicolumn{3}{c}{\em meaning}\\
500 \em(hex) & \em(dec.) & \em Set A & \em Set B & \em Set C\\
501 0x80 & 96 & FNC3 & FNC3 & 96\\
502 0x81 & 97 & FNC2 & FNC2 & 97\\
503 0x82 & 98 & SHIFT & SHIFT & 98\\
504 0x83 & 99 & CODE C& CODE C& 99\\
505 0x84 & 100 & CODE B& FNC4 & CODE B\\
506 0x85 & 101 & FNC4 & CODE A& CODE A\\
507 0x86 & 102 & FNC1 & FNC1 & FNC1\\
508 0x87 & 103 & START A& START A& START A\\
509 0x88 & 104 & START B& START B& START B\\
510 0x89 & 105 & START C& START C& START C\\
511 0x8a & 106 & STOP & STOP & STOP
512 \end{tabular}
513
514 But please keep in mind that {\tt codean.pl} does almost anything for you,
515 you should not have the need to insert start/stop codes and the
516 like. Only if you use EAN128, you will need {\tt FNC1}. Just to make
517 it clear: For your barcode to include {\tt FNC1} you have to write
518 \verb|^^86| before preprocessing.
519
520 {\tt codean.pl} will insert a sequence of hex digits; the original
521 text will be appended to the line as a comment.
522 Also, your \TeX{} file has to define some macros. They look like
523 this:
524
525 \begin{verbatim}
526 \font\fntcxx=wlc128 scaled \magstep3
527 \def\CXXVIII{\bgroup\fntcxx\let\next\hexchar\next}
528 \def\cxxviii{\message{OOPS, use codean.pl}}
529 \def\hexchar#1#2{\if#1@
530 \global\let\next\egroup
531 \else\char"#1#2\fi\next}
532 \end{verbatim}
533
534 If you do not like end recursion, you might use other ones. If
535 you dislike the hex format produced by {\tt codean.pl}, you are free to
536 change it---as long as you don't redistribute.
537
538 \subsection{A little bit about code 11}
539
540 Code 11 is a numeric-only barcode. It is almost as space-efficient as
541 {\sc itf}, and it comes with a checksum. The checksum should be
542 swallowed by the reading device. The checksum is a weighted mod-11
543 checksum. There are apparently two kinds of checksum in use: such with
544 one checkdigit and such with two checkdigits.
545
546 To use code 11, you should include {\tt barcode.sty}. \TeX{} will
547 calculate the checksum on its own. If you need two check digits, you
548 should say\\
549 {\tt\tbs codexichecksumktrue}.\\
550 How many check digits you
551 actually need should be made clear in the documentation to your
552 reading device\footnote{You may also want to check the documentation
553 to find out if your reading device supports code 11 at all; code 11 is
554 not that common.}. You may code the digits 0--9, and the minus
555 sign. The start and stop sign is mapped to the @ character. Here is a
556 full example. {Please note: If you do not use \LaTeX{}, you may
557 have to supply a definition for {\tt\tbs makeatletter}
558 and {\tt\tbs makeatother}}:
559
560 \begin{verbatim}
561 \input barcodes.sty
562 %% with two check digits
563 \codexichecksumktrue
564 \codxi{12-1234}
565
566 %% with only one check digit.
567 \codexichecksumkfalse
568 \codxi{12-1234}
569 \bye
570 \end{verbatim}
571
572 \subsection{Which Code 39 should I use, there are different versions?}
573
574 Well, you may \verb|\input code39| in your \TeX\ document to get the
575 macro version. It is absolutely flexible in repect of barcode size and
576 so on, but it is made of \TeX\ macros and there are probably
577 situations where you may prefer a {\em real} font. So there is {\tt
578 wlc39.mf} as a real font, {\tt wlcr39.mf} as a font running sideways,
579 and{\tt wlcf39.vpl} as a full ascii code 39 in vpl format. The
580 ltter two fonts are experimental, that means, they are not that much
581 tested as the others.
582
583 I recommend using either the \TeX\ macro or {\tt wlc39.mf}. The others
584 are too special for normal use, rotation by the graohics driver is
585 mor robust than building towers of letters, and full ascii code~39 is
586 less than optimal.
587
588 \subsection{About code 93}
589
590 Code 93 is a little bit more compact than code 39 (as it uses also the
591 gap between the characters), but in other aspects it is quite
592 similiar. A checksum with two digits is mandatory. As with code 11,
593 checksumming works by weighing the characters different depending on
594 their position within the barcode.
595
596 The version of code 93 that is included within the package resorts to
597 uppercase ascii, digits, and to some other signs. Start and stop sign
598 are mapped to {\tt<} and {\tt>}, respectively.
599
600 Full ascii works similiar to full ascii with code 39 (that means with
601 escape characters), but fortunately the escape characters are
602 different from ordinary characters, so that you can hardly be
603 misunderstood. Unfortunately the escape characters are named (\$),
604 (\%), (/), and (+), so I decided to map them to opening and closing
605 parentheses and brackets, respectively. This may not seem very clever
606 when it comes to full ascii, but these characters may also appear as
607 checksum characters, so we need them when doing uppercase ascii,
608 too. For full ascii, it would be clever to redo the font in a
609 completely different way and to map start sign, stop sign and the four
610 escape characters to positions above 128, so that any 7 bit ascii
611 character can be input directly.
612
613 Code 93 is supported by codean.pl in the same way as ean or code 128
614 are. You have to write {\tt\tbs xciii\{YOUR DATA 123\}}, run the file
615 through {\tt codean.pl}, then you'll get\\
616 {\tt\tbs XCIII\{YOUR DATA 123NN\}\%Code93(YOUR DATA 123)}
617
618 The NN make up the two check characters. Normally, they are different,
619 but in this example they are equal, by incident.
620
621 \subsection{Docs about VPL Files}
622
623 VPL files are documented in the files {\tt VPtoVF.WEB} and {\tt
624 VFtoVP.WEB}. Both files can be found on {\sc ctan} under {\tt
625 SYSTEMS/KNUTH}. {\em WEAVE} may be used to produce \TeX{} files. The
626 documentation about the VPL/VF file formats is covered within the
627 first few sections.
628
629 \section{I want other metrics etc.}
630
631 \subsection{My barcodes should have depth}
632
633 You have got several possibilities to obtain depth. The most simple
634 approach may be to set the barcodes with the regular barcode fonts into an
635 {\tt\tbs hbox} and then to {\tt\tbs lower} this hbox.
636
637 Let's look at an example:
638
639 \begin{verbatim}
640 \font\itf=wlitf scaled 1200
641 \def\bcbox#1{\lower3pt\hbox{\itf +#1-}}
642 Example:
643 {\sc itf} barcode looks like \quad\bcbox{1009}\quad
644 for 1009, e.g.
645 \end{verbatim}
646
647 This code yields the following result:
648
649 {\sc itf} barcode looks like \quad\bcbox{1009}\quad for 1009, e.g.
650
651 Another approach is to edit the font sources. In case of {\sc vpl}
652 files, this is quite painful. Rules in {\sc vpl} files do not have
653 depth, so you have to change the characters mapping in a way that you
654 add a {\em movedown} before you draw, and a {\em moveup} afterwards.
655 You may see the changes for an arbitrary character from {\tt
656 WLITF.VPL}:
657
658 \begin{verbatim}
659 (CHARACTER D48
660 (COMMENT from WLITF.VPL}
661 (CHARWD D 14) (CHARHT R 10)
662 (CHARDP R 0) (CHARIC R 0.0)
663 (MAP
664 (SETRULE R 14 R 1)(MOVERIGHT R 1)
665 (SETRULE R 14 R 1)(MOVERIGHT R 1)
666 (SETRULE R 14 R 2)(MOVERIGHT R 2)
667 (SETRULE R 14 R 2)(MOVERIGHT R 2)
668 (SETRULE R 14 R 1)(MOVERIGHT R 1)
669 )
670 )
671 \end{verbatim}
672
673 This character may be lowered by four units by editing in a way that the
674 following lines result. Please note that there were not only the {\em
675 moveup} and {\em movedown} commands added, but also the height an
676 depth have been changed.
677
678 \begin{verbatim}
679 (CHARACTER D48
680 (COMMENT Lowered to give some depth)
681 (CHARWD D 14) (CHARHT R 10)
682 (CHARDP R 4) (CHARIC R 0.0)
683 (MAP
684 (MOVEDOWN R 4)
685 (SETRULE R 14 R 1)(MOVERIGHT R 1)
686 (SETRULE R 14 R 1)(MOVERIGHT R 1)
687 (SETRULE R 14 R 2)(MOVERIGHT R 2)
688 (SETRULE R 14 R 2)(MOVERIGHT R 2)
689 (SETRULE R 14 R 1)(MOVERIGHT R 1)
690 (MOVEUP R 4)
691 )
692 )
693 \end{verbatim}
694
695 \subsection{My barcodes are too tall}
696
697 For the sake of the person who has to scan the barcodes, barcodes just
698 can't be tall enough. If the complete code is as tall as wide, the
699 reading device can be twisted against the code at an angle of 45
700 degrees. If they are half as high, the angle reduces to 26 degrees.
701
702 If you really want short codes, you have to edit the sources. In the
703 {\sc vpl} file, you have to change the {\em charht} and the first parameter
704 to the {\em setrule} command at well. You also should change the {\em
705 designsize} parameter.
706
707 For the EAN font, search for {\tt bheight\#} and change {\tt22.85
708 mm\#} to the height you need. To get an EAN font without the digits
709 (bars only), you also have to edit the character definitions by
710 leaving out the last lines (saying {\tt nuller;}, e.g. and you have to
711 change the formula for calculating {\tt totheight} to not include the
712 height of the digits any more, also you should remove any references
713 to {\tt klotz}.
714
715 \subsection{My barcodes are not tall enough}
716
717 You may also change the sources, like described in the previous
718 subsection. But there is another solution that is perhaps more
719 practical. The idea is simple that double black is still black and
720 that you may overlay several printouts of the same barcode. Here is
721 the example code (it may be made taller by adding more copies of the
722 barcode box, of course). There is an extra dimension {\em bcboxdepth}
723 added to yield depth for the barcodes.
724
725 \begin{verbatim}
726 \newbox\bsavebox
727 \newdimen\bcboxdepth
728 \bcboxdepth=4pt
729 \def\bdbox#1{\setbox\bsavebox\hbox{\itf +#1-}
730 \vbox{\hsize=\wd\bsavebox\copy\bsavebox%
731 \vskip-\ht\bsavebox\vskip\bcboxdepth%
732 \box\bsavebox\vskip-\bcboxdepth}}
733 \def\bebox#1{\setbox\bsavebox\hbox{\itf +#1-}
734 \vbox{\hsize=\wd\bsavebox\copy\bsavebox%
735 \vskip0pt\copy\bsavebox%
736 \vskip-\ht\bsavebox\vskip\bcboxdepth%
737 \box\bsavebox\vskip-\bcboxdepth}}
738 Example:
739 Tall {\sc itf} barcode looks like \quad\bdbox{1009}\quad
740 or (still taller) \quad\bebox{1009}\quad for 1009, e.g.
741 \end{verbatim}
742
743 And here is the result, you may compare it with the output of the
744 previous example:
745
746 Tall {\sc itf} barcode looks like \quad\bdbox{1009}\quad or (still
747 taller) \quad\bebox{1009}\quad for 1009, e.g.
748
749 \subsection{My barcodes are too wide/too narrow}
750
751 Perhaps you should change the barcode size (by changing
752 {\tt\tbs magnification}) and then read the subsections above about too
753 tall bars and bars that are not tall enough.
754
755 \subsection{My barcodes should run vertically}
756
757 Vertically oriented barcode is a good idea for cans, bottles and
758 similiar things.
759
760 It just depends on your {\sc dvi} driver. Perhaps there is a
761 possibility to handle rotation via {\tt\tbs special}, as with {\em
762 dvips} and the {\em rotate} macros. For experimantal purposes I have
763 included a code 39 version running down instead right ({\tt
764 wlcr39.mf}). You may perhaps use it with {\tt\tbs shortstack} or
765 similiar. Here is some code I used (successfully) with plain \TeX:
766
767 \begin{verbatim}
768 \font\testfont=wlcr39 scaled 1200
769 \def\bcbax{\let\next\bcbox\vbox\bgroup
770 \offinterlineskip\testfont\setbox0\hbox{@}\hsize=\wd0
771 \noindent{}@\hfil\break\next}
772 \def\fertig{@\hfil\break\egroup}
773 \def\bcbox#1{\if @#1\let\next\fertig\else#1\hfil\break\fi\next}
774
775 Look buddy, this is \bcbax1406632@ code 39
776 stacked and running downwards.
777 \end{verbatim}
778
779 \subsection{I heard something about full ascii code 39}
780
781 Well, umh, now that you ask\dots The truth is: You may perhaps be able to
782 configure your reading device to accept full ascii code~39. Then you may
783 code any 7~bit character you may think of. The bad news is that most of
784 the symbols have to be coded by two
785 characters -- and as code 39 has already low density, you should not
786 expect to get much use of it. Perhaps you might want to try code 128
787 instead---it features full 7-bit ascii without any compromise.
788
789 Another anti-feature is that switching to reading full-ascii code~39
790 may lead to some bad reads of `normal' code~39. In full ascii, the lower
791 case letters, e.g., are made by prepending the uppercase letters with a
792 plus sign, so {\tt+A} is read as {\tt a}. So, if you have got regular
793 code~39 that contains such character sequences, and you have switched
794 your reading device to full ascii, you may get bad results.
795
796 But, now that you want it: With the barcode package there comes a font
797 {\tt wlcf39.vpl}. You may install it like the other vpl files. It has got
798 132 characters and has already taken all the coding for full ascii, so
799 when you typ {\tt e,\$4+A}, it will silently be mapped to what you
800 would have typed as {\tt+E/L/D/KA}, if you would use the plain code~39
801 format\footnote{Please take note: 6 characters are blown up to 9,
802 think again about using another code}. In my version of full ascii
803 code~39, the start/stop sign is mapped to @@ (or \verb|\char128|). So
804 you actually had to add @@ to the front and the end of the example
805 string. If you can not exclude that the character sequence @@ appears
806 within the text you want to code, you have to avoid ligature
807 processing. You may do that like this:
808
809 \begin{verbatim}
810 \font\fullas=wlcf39 scaled 1728
811 \def\alphanolig{\char64\kern0pt}
812 \def\printacode#1{{\fullas@@{\catcode`\@=\active%
813 \let @=\alphanolig#1}@@}}
814 \end{verbatim}
815
816 You also have to escape or circumscribe special characters to make
817 them really printable, of course, so that when you wanted a backspace,
818 a tab, a space, a dollar sign, a percent sign, and a bell character to
819 be coded, you would type something like
820
821 \begin{verbatim}
822 {\fullas @@\char8\char9\char32\$\%\char7}
823 \end{verbatim}
824
825 \section{Troubleshooting}
826
827 \subsection{My barcodes can't be decoded}
828
829 At the very, very first, check if you really have added start and stop
830 codes. If you haven't, you're lost. Then check if you have enabled
831 decoding of your special barcodes within your reading device. With
832 modern scanners, you can disable almost any coding scheme.
833
834 At first, try to make them larger. If that does't help, make them
835 larger, again. If that will not help, obtain fonts in \TeX{} or
836 Metafont format and make them brighter. Or, perhaps better, obtain a
837 better printer.
838
839 You also should check the contrast between bars and background,
840 especially when using a dot matrix printer or coloured background
841 or---still worse---red bars.
842
843 \subsection{My decoder reads extra digits, sometimes}
844
845 I guess you use {\sc itf} barcode with a number of digits that is
846 sometimes even and sometimes odd. As {\sc itf} always codes two digits
847 at once, you should take care just to code an even number of digits at
848 any time. If an excess zero at the beginning of your number is not
849 acceptable, you might try another kind of barcode instead of {\sc
850 itf}.
851
852 \subsection{Can't run pdf\TeX\ with barcode fonts}
853
854 Get a later version of pdf\TeX, and you're done.
855
856 \section{Missing items}
857
858 \subsection{I am missing two-of-five}
859
860 I got specs for two-of-five (three bars). If you want it, let me know;
861 I might implement it. For other kinds of two-of-five, I haven't got
862 complete specs.
863
864 \subsection{I am missing plessey}
865
866 I got the specs but I haven't yet got the time to implement them. With
867 plessey, there also rise several questions due to the fact that
868 plessey has never been officialy standardized. The only thing that is
869 absolutely sure about plessey is how binary ones and zeros are
870 encoded. There are codes that are more wide-spread. Several modern
871 barcode readers can't cope with plessey code.
872
873 \subsection{I am missing \dots{} some other barcode}
874
875 I have checked out several two-dimensional barcodes. But for most of
876 them, support by \TeX{} seems to be rather pointless. Perhaps Metafont
877 could be called any time you have to code something to draw the
878 symbols, but you might as well use a custom drawing program that comes
879 from the barcode vendor. Also, most two-dimensional barcodes (and
880 other barcodes not mentioned here) are proprietary. Last not least the
881 reading devices I have access to can deal only with a finite range of
882 barcodes.
883
884 I am sorry, but I haven't got the specs for further barcodes
885 not mentioned here. If you could be so kind as to send them to me, I
886 might perhaps implement them.
887
888 \section{Contributions}
889
890 \subsection{EAN without preprocessing}
891
892 The following code is due to Kalvis M. Jansons.
893
894 It handles printing of {\sc ean} without having to run a
895 preprocessor. Not only are the {\sc ean} bars drawn, also the checksum
896 checksum is checked. It can be easily
897 adapted to non-\LaTeX{} use by omitting anything before \verb|\font|
898
899 \begin{verse}
900 Kalvis M. Jansons
901
902 eMail: \verb|<[email protected]>|
903
904 \end{verse}
905
906 An easy way to use the barcode fonts in \LaTeX{}:
907
908 \begin{verbatim}
909 \documentclass[a4paper]{article}
910
911 \pagestyle{empty}
912
913 \setlength{\oddsidemargin}{0pt}
914 \setlength{\textwidth}{\paperwidth}
915 \addtolength{\textwidth}{-2in}
916 \setlength{\marginparwidth}{0pt}
917
918 \setlength{\textheight}{\paperheight}
919 \addtolength{\textheight}{-2.5in}
920 \setlength{\topmargin}{0pt}
921
922 \font\eanfont=WLEAN scaled 2000
923 \def\ean#1{\vbox{\vskip20pt\eanfont#1\vskip20pt}}
924 \newcount\num
925 \def\a#1{\num=#1 \advance\num by `A \char\num}
926 \def\b#1{\num=#1 \advance\num by `a \char\num}
927 \def\c#1{\num=#1 \advance\num by `K \char\num}
928 \def\C#1#2#3#4#5#6{\c#1\c#2\c#3\c#4\c#5\c#6}
929
930 \def\A#1#2#3#4#5#6#7{\ifcase #7
931 {\a#1\a#2\a#3\a#4\a#5\a#6}%
932 \or {\a#1\a#2\b#3\a#4\b#5\b#6}%
933 \or {\a#1\a#2\b#3\b#4\a#5\b#6}%
934 \or {\a#1\a#2\b#3\b#4\b#5\a#6}%
935 \or {\a#1\b#2\a#3\a#4\b#5\b#6}%
936 \or {\a#1\b#2\b#3\a#4\a#5\b#6}%
937 \or {\a#1\b#2\b#3\b#4\a#5\a#6}%
938 \or {\a#1\b#2\a#3\b#4\a#5\b#6}%
939 \or {\a#1\b#2\a#3\b#4\b#5\a#6}%
940 \or {\a#1\b#2\b#3\a#4\b#5\a#6}%
941 \fi}
942
943 \newcount\cha
944 \newcount\chb
945 \makeatletter
946 \long\def\for{\@for}
947 \makeatother
948 \gdef\mysix#1#2#3#4#5#6{,#1#2,#3#4,#5#6}
949 \gdef\mywork#1#2{\advance\cha by #1 \advance\chb by #2}
950 \gdef\barch#1.#2.#3.{
951 \xdef\mylist{0#1\mysix#2\mysix#3}
952 \cha=0
953 \chb=0
954 \for \x:=\mylist\do{\expandafter\mywork\x}
955 \multiply\cha by 3
956 \advance\chb by \cha
957 \cha=\chb
958 \divide\cha by 10
959 \multiply\cha by -10
960 \advance\chb by \cha}
961 \def\bar#1.#2.#3.{\barch#1.#2.#3.
962 \ifnum\chb>0 #1#2#3 has a bad check sum!\\[20pt]
963 \else \ean{#1 +\A#2#1-\C#3+}\fi}
964 \begin{document}
965
966 Examples
967
968 \bar3.034325.106199.
969
970 \bar4.074400.410000.
971
972 \bar5.449000.055521.
973
974 \bar5.010027.522336.
975
976 \bar8.410005.421052.
977
978 \bar9.780192.828941.
979
980 \end{document}
981 \end{verbatim}
982
983 \section{Installation}
984
985 Installation is described within the README file, in short.
986 Here I assume that you have a TDS compliant \TeX{} installation
987 already running.
988
989 Installation consists of several steps:
990
991 \begin{enumerate}
992 \item unpack barcodes.dtx by running barcodes.ins through \TeX (I
993 guess you have already done that, lest you would not be able to read
994 this text), like {\tt tex barcodes.ins}
995 \item run {\tt vptovf} on all the vpl files, e.g. type something like
996 {\tt vptovf wlitf.vpl wlitf.vf wlitf.tfm}
997 \item if your \TeX\ system does not support automatic generation of
998 {\tt tfm} files, run mf on all the .mf files.
999 \item move all the files to appropriate locations
1000 \item install codean.pl for use with Perl
1001 \item run the documentation through \LaTeX{}
1002 \item clean up
1003 \end{enumerate}
1004
1005 Items 1,2,4,6, and part of 7 can be automatically executed on ms-dos or
1006 ms windows systems by running {\tt install.bat}. If you do not supply
1007 any parameters, {\tt install} will install to {\tt C:\char92TeXMF}. If
1008 you do supply a parameter, it should be the path to your TEXMF tree
1009 (no trailing backslash, please).
1010
1011 Here are the appropriate locations mentioned above -- all of them
1012 in the TEXMF tree:
1013
1014 \begin{tabular}{ll}
1015 \em move & \em to\\
1016 \tt *.mf & \tt fonts/source/public/misc\\
1017 \tt *.tfm & \tt fonts/tfm/public/misc\\
1018 \tt *.vf & \tt fonts/vf/public\\
1019 \tt code39.tex &\tt tex/generic/misc\\
1020 \tt barcodes.sty &\tt tex/latex/misc\\
1021 \end{tabular}
1022
1023 Of course other locations might also work, but to me it seems fine
1024 this way.
1025
1026 Running plain \TeX{} on {\tt examples.tex} is the ultimate test: This
1027 will only work when all the installation is well done.
1028
1029 The installation of Perl programs is beyond the scope of this
1030 documentation. If you do not need code 128, you can go without
1031 {\tt codean.pl}, especially if you use the macros described above.
1032
1033 \bibliography{bcfaq}
1034
1035 \end{document}
1036 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1037 % % general documentation ends here %%
1038 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1039 %</bcfaq>
1040 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1041 % % bibliography for general documentation %%
1042 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1043 %<*bcfaqbbl>
1044 \begin{thebibliography}{Sau92}
1045
1046 \bibitem[Ol{\v{s}}94]{bc:ean}
1047 Peter Ol{\v{s}}ak.
1048 \newblock The ean barcodes by {\TeX}.
1049 \newblock {\em TUGboat}, 15(4):459--464, 1994.
1050
1051 \bibitem[Sau92]{bc:sauter}
1052 John Sauter.
1053 \newblock Postnet codes using metafont.
1054 \newblock {\em TUGboat}, 13(4):472--476, 1992.
1055
1056 \bibitem[Vul91]{bc:vulis}
1057 Dimitri Vulis.
1058 \newblock {\TeX} and envelopes.
1059 \newblock {\em TUGboat}, 12(2):279--284, 1991.
1060
1061 \end{thebibliography}
1062 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1063 % % end of bibliography for general documentation %
1064 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1065 %</bcfaqbbl>
1066 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1067 % % example sheet starts here %
1068 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1069 %<*example>
1070 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1071 %%
1072 %% This file documents look and use of
1073 %% the barcodes this package belongs to.
1074 %% It may be freely used without any
1075 %% further permission.
1076 %% You should have received this file as part of
1077 %% the barcode package.
1078 %%
1079 %% Author: Peter Willadt
1080 %% Date: 1997-11-29
1081 %%
1082 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1083 %%
1084 %% Note:
1085 %% 1. This file has already been run through codean.pl
1086 %%
1087 %% 2. You need to have the fonts installed, of course.
1088 %%
1089 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1090 %% Fonts
1091 %%
1092 \font\xlix=wlc39 scaled 2000
1093 \font\itf=wlitf scaled 2000
1094 \font\cdb=wlcdb scaled 2000
1095 \font\eanfont=WLEAN scaled 1200
1096 \font\fntcxx=wlc128 scaled \magstep3
1097 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1098 %% Inputs
1099 %%
1100 \input code39.tex
1101 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1102 %% Def's
1103 %%
1104 %% for EAN
1105 \def\ean#1{\message{Call codean.pl}}
1106 \def\eean#1{\message{Call codean.pl}}
1107 \def\isbn#1{\message{Call codean.pl}}
1108 \def\embed#1{}
1109 \def\EAN#1{\vbox{\hsize=0.4\hsize\vskip10pt\eanfont#1\vskip10pt}}
1110 %% for Code 128
1111 \def\CXXVIII{\bgroup\fntcxx\let\next\hexchar\next}
1112 \def\hexchar#1#2{\if#1@\global\let\next\egroup\else\char"#1#2\fi\next}
1113 %%
1114 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1115 %% Here we go
1116 \parindent0pt
1117 Hello, this is a test sheet of the barcode fonts.
1118
1119 At first, we deal with code 39. Code 39 is represented in this package
1120 both in form of a native font (Metafont-source) and in form of
1121 \TeX{}-macros. code 39 features low-density alphanumeric encoding.
1122
1123 Here you may see how HELLO looks like in code 39 (the start and stop
1124 sign is mapped to @, if you're curious, so in the source to this sheet
1125 I have written {\tt@HELLO@} after having selected the proper
1126 font). This first example uses the font.
1127
1128 {\xlix@HELLO@}
1129
1130 Another approach is to use \TeX{} macros to make up bars. Here is the
1131 same HELLO with macros: Please note that for the macro version, you
1132 have to use the underbar if you want to have a space coded.
1133
1134 \begincodethirtynine{HELLO}\endcodethirtynine
1135
1136 Interleaved two-of-five (ITF for short) features high-density
1137 numerical-only encoding. Your code has to have an even number of
1138 digits. The start sign is mapped to $+$, the end sign to $-$.
1139 So, to code 0123456789, you type {\tt+0123456789-}, and the result
1140 looks like this:
1141
1142 {\itf+0123456789-}
1143
1144 If you still have not got enough of barcoding, here is codabar. Here
1145 you got four sets of start/stop signs that get decoded together with
1146 the numbers. The start/stop sign pairs are a/t, b/n, c/*, and d/e. So
1147 {\tt a12345t} looks like this:\bigskip
1148
1149 {\cdb a12345t}
1150
1151 Now you should have a look at code 128. The bars itself look sometimes
1152 disrupted; this is due to the fact that the widest elements are four
1153 times as wide as the narrowest. Code 128 enables you to code any 7-bit
1154 ascii character. With digits only, it is as efficent as itf. The bad
1155 news is the preprocessing required, so you have to read the docs. The
1156 following bars mean {\tt Hallo123456}\bigskip
1157
1158 \CXXVIII 6828414C4C4F630C2238506A@@ % Code128(Hallo123456)
1159
1160
1161 And, last and perhaps most important, the EAN font. Read {\tt
1162 eandoc.tex} to find out how these are coded, here is just the output
1163 of the example code mentioned there:
1164 \embed{2500000000000}
1165
1166 \line{
1167 \EAN{4 +AcFHaa-KKLKNK+} % or, without checksum: %(4025700001030)
1168 \hfil
1169 \EAN{4 +AcFHaa-KKLKNK+} %(402570000103)
1170 }
1171 \line{
1172 \EAN{2 +FAaaAa-KKLMNT+} % embedded(123)
1173 \hfil
1174 \EAN{9 +HiaCaB-LNOOSN+} % ISBN(0201134489)
1175 }
1176
1177 And that's all. Perhaps you may think that this is not a beautiful
1178 document---but barcodes aren't beautiful. As long as reading devices
1179 do not have \ae{}sthetic feelings, I don't regard this as a problem.
1180 \bye
1181 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1182 % % example sheet ends here %
1183 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1184 %</example>
1185 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1186 % % style file starts here %
1187 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1188 %<*bcsty>
1189 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1190 %% Options for using barcodes %%
1191 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1192 %% documented in bcfaq.tex %%
1193 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1194 %% itf stuff
1195 %% general
1196 \font\xlix=wlc39 scaled 2000
1197 \font\fntxciii=wlc93 scaled 2000
1198 \font\itf=wlitf scaled 2000
1199 \font\cdb=wlcdb scaled 2000
1200 \font\eanfont=wlean scaled 1200
1201 \font\fntcxx=wlc128 scaled \magstep3
1202 %% barcodes with depth
1203 \def\bcbox#1{\lower3pt\hbox{\itf +#1-}}
1204 %% barcodes made taller
1205 \newbox\bsavebox
1206 \newdimen\bcboxdepth
1207 \bcboxdepth=4pt
1208 \def\bdbox#1{\setbox\bsavebox\hbox{\itf +#1-}
1209 \vbox{\hsize=\wd\bsavebox\offinterlineskip%
1210 \copy\bsavebox%
1211 \vskip-\ht\bsavebox\vskip\bcboxdepth%
1212 \box\bsavebox\vskip-\bcboxdepth}}
1213 \def\bebox#1{\setbox\bsavebox\hbox{\itf +#1-}
1214 \vbox{\hsize=\wd\bsavebox\offinterlineskip%
1215 \copy\bsavebox%
1216 \copy\bsavebox%
1217 \vskip-\ht\bsavebox\vskip\bcboxdepth%
1218 \box\bsavebox\vskip-\bcboxdepth}}
1219 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1220 %% Code 128 stuff
1221 \font\fntcxx=wlc128 scaled \magstep3
1222 \def\XCIII#1{\bgroup\fntxciii #1}
1223 \def\CXXVIII{\bgroup\fntcxx\let\next\hexchar\next}
1224 \def\cxxviii{\message{OOPS, use codean.pl}}
1225 \def\hexchar#1#2{\if#1@
1226 \global\let\next\egroup
1227 \else\char"#1#2\fi\next}
1228 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1229 %% Code 11 stuff
1230 \font\codxifnt=wlc11 scaled\magstep2
1231 %% relies on counters \cha and \chb defined below
1232 \newif\ifcodexichecksumk
1233 \codexichecksumkfalse
1234 \makeatletter
1235 \def\check@xichar{%
1236 \ifcodexichecksumk%
1237 {\count0=\cha\count1=\count0\divide\count1by11%
1238 \multiply\count1by11\advance\count0by-\count1%
1239 \ifnum10=\count0-\else\relax\the\count0\fi%
1240 \global\advance\chb by\count0\global\advance\cha by\chb%
1241 }\fi
1242 \chb=\cha\divide\chb by11%
1243 \multiply\chb by11\advance\cha by-\chb%
1244 \ifnum10=\cha-\else\the\cha\fi%
1245 }
1246 \def\csumxi#1{%
1247 \if @#1%
1248 \let\next\check@xichar%
1249 \else \if-#1\advance\chb by10%
1250 \else\advance\chb by#1%
1251 \fi%
1252 \advance\cha by\chb%
1253 #1%
1254 \fi%
1255 \next%
1256 }
1257 \makeatother
1258 \def\codxi#1{{
1259 \codxifnt
1260 \cha=0\chb=0%
1261 @\let\next\csumxi\expandafter\expandafter\expandafter\csumxi#1@@
1262 }}
1263 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1264 % misc things
1265 \font\codtnfnt=wlc39 scaled\magstep2
1266 \def\codxxxix#1{{\codtnfnt @#1@}}
1267 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1268 %% EAN stuff
1269 %% this code comes from Kalvis M. Jansons
1270 %% eMail: <[email protected]>
1271 %%
1272 \font\eanfont=WLEAN scaled 2000
1273 \def\ean#1{\vbox{\vskip20pt\eanfont#1\vskip20pt}}
1274 \newcount\num
1275 \def\a#1{\num=#1 \advance\num by `A \char\num}
1276 \def\b#1{\num=#1 \advance\num by `a \char\num}
1277 \def\c#1{\num=#1 \advance\num by `K \char\num}
1278 \def\C#1#2#3#4#5#6{\c#1\c#2\c#3\c#4\c#5\c#6}
1279 \def\A#1#2#3#4#5#6#7{\ifcase #7
1280 {\a#1\a#2\a#3\a#4\a#5\a#6}%
1281 \or {\a#1\a#2\b#3\a#4\b#5\b#6}%
1282 \or {\a#1\a#2\b#3\b#4\a#5\b#6}%
1283 \or {\a#1\a#2\b#3\b#4\b#5\a#6}%
1284 \or {\a#1\b#2\a#3\a#4\b#5\b#6}%
1285 \or {\a#1\b#2\b#3\a#4\a#5\b#6}%
1286 \or {\a#1\b#2\b#3\b#4\a#5\a#6}%
1287 \or {\a#1\b#2\a#3\b#4\a#5\b#6}%
1288 \or {\a#1\b#2\a#3\b#4\b#5\a#6}%
1289 \or {\a#1\b#2\b#3\a#4\b#5\a#6}%
1290 \fi}
1291 \newcount\cha
1292 \newcount\chb
1293 \makeatletter
1294 \long\def\for{\@for}
1295 \makeatother
1296 \gdef\mysix#1#2#3#4#5#6{,#1#2,#3#4,#5#6}
1297 \gdef\mywork#1#2{\advance\cha by #1 \advance\chb by #2}
1298 \gdef\barch#1.#2.#3.{
1299 \xdef\mylist{0#1\mysix#2\mysix#3}
1300 \cha=0
1301 \chb=0
1302 \for \x:=\mylist\do{\expandafter\mywork\x}
1303 \multiply\cha by 3
1304 \advance\chb by \cha
1305 \cha=\chb
1306 \divide\cha by 10
1307 \multiply\cha by -10
1308 \advance\chb by \cha}
1309 \def\bar#1.#2.#3.{\barch#1.#2.#3.
1310 \ifnum\chb>0 #1#2#3 has a bad check sum!\\[20pt]
1311 \else \ean{#1 +\A#2#1-\C#3+}\fi}
1312 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1313 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1314 % % style file ends here %
1315 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1316 %</bcsty>
1317 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1318 % % code 39 macro file starts here %
1319 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1320 %<*code39mac>
1321 %%% ====================================================================
1322 %%% @TeX-file{
1323 %%% author = "Peter Willadt",
1324 %%% version = "1",
1325 %%% date = "16 August 1997",
1326 %%% time = "10:00:00 GMT",
1327 %%% filename = "code39.tex",
1328 %%% address = "Peter Willadt
1329 %%% 75177 Pforzheim
1330 %%% Germany",
1331 %%% email = "[email protected]",
1332 %%% codetable = "ISO/ASCII",
1333 %%% keywords = "Barcode, Code39, TeX",
1334 %%% abstract = "This file contains macros to support the inclusion
1335 %%% of code 39 barcode in TeX documents.",
1336 %%% }
1337 %%% ====================================================================
1338 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1339 %% This code supports barcodes in Code 39
1340 %% Usage:
1341 %% For alphanumerical barcodes:
1342 %% \begincodethirtynine followed by
1343 %% the stuff to code,
1344 %% ended with \endcodethirtynine
1345 %% For numerical only code:
1346 %% modify the code for pharamceuticals
1347 %% For german pharmaceutics:
1348 %% \pzncode1234562@ when 1234562 is the
1349 %% number to be coded as -1234562.
1350 %% this will also verify the checksum
1351 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1352 %% This file may be freely used without any
1353 %% further permission.
1354 %% It comes with absolutely no warranty.
1355 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1356 %% this is the common stuff
1357 \newdimen\dick
1358 \newdimen\duenn
1359 \newdimen\duennbar
1360 \newdimen\dickbar
1361 \newdimen\antibleed
1362 \dick=1mm
1363 \duenn=0.5mm
1364 \antibleed=0mm
1365 \dickbar=\dick
1366 \advance\dickbar by -\antibleed
1367 \duennbar=\duenn
1368 \advance\duennbar by -\antibleed
1369 % b means bar
1370 \def\b{\vrule width\duennbar}
1371 \def\B{\vrule width\dickbar}
1372 % s means space
1373 \def\s{\hskip\duenn\hskip\antibleed}
1374 \def\S{\hskip\dick\hskip\antibleed}
1375 %%
1376 \def\tnzero{\b\s\b\S\B\s\B\s\b\s}
1377 \def\tnone{\B\s\b\S\b\s\b\s\B\s}
1378 \def\tntwo{\b\s\B\S\b\s\b\s\B\s}
1379 \def\tnthree{\B\s\B\S\b\s\b\s\b\s}
1380 \def\tnfour{\b\s\b\S\B\s\b\s\B\s}
1381 \def\tnfive{\B\s\b\S\B\s\b\s\b\s}
1382 \def\tnsix{\b\s\B\S\B\s\b\s\b\s}
1383 \def\tnseven{\b\s\b\S\b\s\B\s\B\s}
1384 \def\tneight{\B\s\b\S\b\s\B\s\b\s}
1385 \def\tnnine{\b\s\B\S\b\s\B\s\b\s}
1386 \def\tninestart{\b\S\b\s\B\s\B\s\b\s}
1387 \def\tnineminus{\b\S\b\s\b\s\B\s\B\s}
1388 \def\tnineplus{\b\S\b\s\b\S\b\S\b\s}
1389 \def\tninedollar{\b\S\b\S\b\S\b\s\b\s}
1390 \def\tnineslash{\b\S\b\S\b\s\b\S\b\s}
1391 \def\tninedot{\B\S\b\s\b\s\B\s\b\s}
1392 \def\tninepercnt{\b\s\b\S\b\S\b\S\b\s}
1393 \def\tninespace{\b\S\B\s\b\s\B\s\b\s}
1394 \def\tninelettera{\B\s\b\s\b\S\b\s\B\s}
1395 \def\tnineletterb{\b\s\B\s\b\S\b\s\B\s}
1396 \def\tnineletterc{\B\s\B\s\b\S\b\s\b\s}
1397 \def\tnineletterd{\b\s\b\s\B\S\b\s\B\s}
1398 \def\tninelettere{\B\s\b\s\B\S\b\s\b\s}
1399 \def\tnineletterf{\b\s\B\s\B\S\b\s\b\s}
1400 \def\tnineletterg{\b\s\b\s\b\S\B\s\B\s}
1401 \def\tnineletterh{\B\s\b\s\b\S\B\s\b\s}
1402 \def\tnineletteri{\b\s\B\s\b\S\B\s\b\s}
1403 \def\tnineletterj{\b\s\b\s\B\S\B\s\b\s}
1404 \def\tnineletterk{\B\s\b\s\b\s\b\S\B\s}
1405 \def\tnineletterl{\b\s\B\s\b\s\b\S\B\s}
1406 \def\tnineletterm{\B\s\B\s\b\s\b\S\b\s}
1407 \def\tninelettern{\b\s\b\s\B\s\b\S\B\s}
1408 \def\tninelettero{\B\s\b\s\B\s\b\S\b\s}
1409 \def\tnineletterp{\b\s\B\s\B\s\b\S\b\s}
1410 \def\tnineletterq{\b\s\b\s\b\s\B\S\B\s}
1411 \def\tnineletterr{\B\s\b\s\b\s\B\S\b\s}
1412 \def\tnineletters{\b\s\B\s\b\s\B\S\b\s}
1413 \def\tninelettert{\b\s\b\s\B\s\B\S\b\s}
1414 \def\tnineletteru{\B\S\b\s\b\s\b\s\B\s}
1415 \def\tnineletterv{\b\S\B\s\b\s\b\s\B\s}
1416 \def\tnineletterw{\B\S\B\s\b\s\b\s\b\s}
1417 \def\tnineletterx{\b\S\b\s\B\s\b\s\B\s}
1418 \def\tninelettery{\B\S\b\s\B\s\b\s\b\s}
1419 \def\tnineletterz{\b\S\B\s\B\s\b\s\b\s}
1420 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1421 %% this is the code for 39 mode
1422 \def\activatethemall{
1423 \catcode`\A=\active \catcode`\B=\active
1424 \catcode`\C=\active \catcode`\D=\active
1425 \catcode`\E=\active \catcode`\F=\active
1426 \catcode`\G=\active \catcode`\H=\active
1427 \catcode`\I=\active \catcode`\J=\active
1428 \catcode`\K=\active \catcode`\L=\active
1429 \catcode`\M=\active \catcode`\N=\active
1430 \catcode`\O=\active \catcode`\P=\active
1431 \catcode`\Q=\active \catcode`\R=\active
1432 \catcode`\S=\active \catcode`\T=\active
1433 \catcode`\U=\active \catcode`\V=\active
1434 \catcode`\W=\active \catcode`\X=\active
1435 \catcode`\Y=\active \catcode`\Z=\active
1436 \catcode`+=\active \catcode`-=\active
1437 \catcode`\_=\active \catcode`.=\active
1438 \catcode`\$=\active \catcode`\%=\active
1439 \catcode`\/=\active
1440 \catcode`\0=\active \catcode`\1=\active
1441 \catcode`\2=\active \catcode`\3=\active
1442 \catcode`\4=\active \catcode`\5=\active
1443 \catcode`\6=\active \catcode`\7=\active
1444 \catcode`\8=\active \catcode`\9=\active
1445 }
1446 {\activatethemall
1447 \gdef\begincodethirtynine{
1448 \bgroup\activatethemall\strut\tninestart
1449 \letA=\tninelettera \letB=\tnineletterb
1450 \letC=\tnineletterc \letD=\tnineletterd
1451 \letE=\tninelettere \letF=\tnineletterf
1452 \letG=\tnineletterg \letH=\tnineletterh
1453 \letI=\tnineletteri \letJ=\tnineletterj
1454 \letK=\tnineletterk \letL=\tnineletterl
1455 \letM=\tnineletterm \letN=\tninelettern
1456 \letO=\tninelettero \letP=\tnineletterp
1457 \letQ=\tnineletterq \letR=\tnineletterr
1458 \letS=\tnineletters \letT=\tninelettert
1459 \letU=\tnineletteru \letV=\tnineletterv
1460 \letW=\tnineletterw \letX=\tnineletterx
1461 \letY=\tninelettery \letZ=\tnineletterz
1462 \let+=\tnineplus \let-=\tnineminus
1463 \let_=\tninespace \let.=\tninedot
1464 \let$=\tninedollar \let%=\tninepercnt
1465 \let/=\tnineslash
1466 \let0=\tnzero \let1=\tnone
1467 \let2=\tntwo \let3=\tnthree
1468 \let4=\tnfour \let5=\tnfive
1469 \let6=\tnsix \let7=\tnseven
1470 \let8=\tneight \let9=\tnnine
1471 }
1472 }
1473 \def\endcodethirtynine{
1474 \tninestart\egroup
1475 }
1476 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1477 %% this code is used for german pharmaceutics
1478 \newcount\ziffern
1479 \newcount\checksum
1480 \newcount\multreg
1481 \def\tndigit#1{%
1482 \ifcase#1\tnzero\or\tnone%
1483 \or\tntwo\or\tnthree%
1484 \or\tnfour\or\tnfive%
1485 \or\tnsix\or\tnseven%
1486 \or\tneight\or\tnnine%
1487 \fi}
1488 \def\endtncode{%
1489 \tninestart%
1490 \ifnum\ziffern=9
1491 \else\message{wrong digit count}
1492 \fi%
1493 \ifnum\checksum=0
1494 \else\message{wrong checksum}
1495 \fi%
1496 \egroup}
1497 \def\nexttn#1{%
1498 \advance\ziffern by1
1499 \if@#1\let\next\endtncode
1500 \else
1501 \tndigit#1%
1502 % begin checksum stuff
1503 \ifnum\ziffern=8
1504 \multreg=\checksum
1505 \divide\multreg by 11
1506 \multiply\multreg by 11
1507 \advance\checksum by-\multreg
1508 \multreg=#1
1509 \advance\checksum by-\multreg
1510 \ifnum\checksum=10
1511 \checksum=0
1512 \fi
1513 \else
1514 \multreg=#1
1515 \multiply\multreg by\ziffern
1516 \advance\checksum by\multreg
1517 \fi%
1518 \fi%
1519 % end checksum stuff
1520 \next}
1521 \def\pzncode{
1522 \bgroup
1523 \let\next\nexttn
1524 \ziffern=1\checksum=0\multreg=0
1525 \strut
1526 \tninestart\tnineminus%
1527 \next%
1528 }
1529 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1530 % % code 39 macro file ends here %
1531 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1532 %</code39mac>
1533 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1534 % % MetaFont Code for Code 11 starts here %
1535 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1536 %<*code11mf>
1537 %% Code 11 in Metafont format
1538 %% Peter Willadt 1998-04-10
1539 %% For copyright and the like see the documentation
1540 %% to the barcode package, from which this file is part of.
1541 %% If you received only this file,
1542 %% then maybe someone fooled you.
1543 %%
1544 %% Code 11 requires one or two check digits.
1545 %% These check digtis are calculated using a weighted mod 11-checksum.
1546 %% You have to see the docs.
1547 %% Start and stop chars are mapped to @,
1548 %% codeable are 0--9 and the minus sign.
1549
1550 mode_setup;
1551
1552 bheight#:=5mm#;
1553
1554 % high res: .264 mm#
1555 % med res: .33 mm#
1556 bwidth# :=.33 mm#;
1557
1558 designsize :=bheight#;
1559 font_slant :=0;
1560 font_normal_space :=8*bwidth#;
1561 font_extra_space :=0;
1562 font_normal_stretch:=0;
1563 font_normal_shrink :=0;
1564 font_quad :=15*bwidth#;
1565
1566 define_pixels(bheight, bwidth);
1567
1568 def CODExichar(expr charnum, spex) =
1569 numeric mywid, asval, i;
1570 mywid=6;
1571 for i= 0 upto 4:
1572 asval:=ASCII(substring(i,i+1) of spex);
1573 asval:=asval-ASCII("0");
1574 mywid:=mywid+asval;
1575 endfor;
1576 beginchar(charnum, mywid*bwidth#,bheight#,0);
1577 y1=y2=0;
1578 y3=y4=bheight;
1579 numeric myright,myleft,barweight,spcweight;
1580 myright:=0;myleft:=0;barweight:=0;spcweight:=0;
1581 for i=0 upto 4:
1582 asval:=ASCII(substring(i,i+1) of spex);
1583 asval:=asval-ASCII("0");
1584 myright:=myright+(asval+1)*bwidth;
1585 if not odd (i):
1586 % actual drawing
1587 x1:=myleft-blacker;
1588 x4:=x1;
1589 x2:=myright+blacker;
1590 x3:=x2;
1591 fill (z1)--(z2)--(z3)--(z4)--cycle;
1592 fi
1593 myleft:=myright;
1594 endfor;
1595 endchar;
1596 enddef;
1597
1598 CODExichar("-","00100");
1599 CODExichar("0","00001");
1600 CODExichar("1","10001");
1601 CODExichar("2","01001");
1602 CODExichar("3","11000");
1603 CODExichar("4","00101");
1604 CODExichar("5","10100");
1605 CODExichar("6","01100");
1606 CODExichar("7","00011");
1607 CODExichar("8","10010");
1608 CODExichar("9","10000");
1609 CODExichar("@","00110");
1610
1611 end;% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1612 % % MetaFont Code for Code 11 ends here %
1613 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1614 %</code11mf>
1615 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1616 % % MetaFont Code for Code 39 starts here %
1617 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1618 %<*code39mf>
1619 %% Code 39, in Metafont mode
1620 %% Willadt 1997-08-17
1621 mode_setup;
1622
1623 bheight#:=5mm#;
1624
1625 %% high res .2 mm,
1626 %% med res .3 mm,
1627 %% lo res .4 mm.
1628
1629 bwidth# :=.3mm#;
1630
1631 designsize :=bheight#;
1632 font_slant :=0;
1633 font_normal_space :=13*bwidth#;
1634 font_extra_space :=0;
1635 font_normal_stretch:=0;
1636 font_normal_shrink :=0;
1637 font_quad :=13*bwidth#;
1638
1639 define_pixels(bheight, bwidth);
1640
1641 def thirtyninechar(expr charnum, spex) =
1642 beginchar(charnum, 13*bwidth#,bheight#,0);
1643 numeric myright,myleft;
1644 numeric asval, i;
1645 myright:=0;myleft:=0;
1646 y1=y2=0;y3=y4=bheight;
1647 for i=0 upto 11:
1648 asval:=ASCII(substring(i,i+1) of spex);
1649 exitif asval=-1;
1650 asval:=asval-ASCII("0");
1651 myright:=myright+asval*bwidth;
1652 if not odd (i):
1653 % actual drawing
1654 x1:=myleft-blacker;
1655 x4:=x1;
1656 x2:=myright+blacker;
1657 x3:=x2;
1658 fill (z1)--(z2)--(z3)--(z4)--cycle;
1659 fi
1660 myleft:=myright;
1661 endfor;
1662 endchar;
1663 enddef;
1664
1665 \thirtyninechar("0")("1112212111");
1666 \thirtyninechar("1")("2112111121");
1667 \thirtyninechar("2")("1122111121");
1668 \thirtyninechar("3")("2122111111");
1669 \thirtyninechar("4")("1112211121");
1670 \thirtyninechar("5")("2112211111");
1671 \thirtyninechar("6")("1122211111");
1672 \thirtyninechar("7")("1112112121");
1673 \thirtyninechar("8")("2112112111");
1674 \thirtyninechar("9")("1122112111");
1675 \thirtyninechar( 64)("1211212111"); % start = @
1676 \thirtyninechar("-")("1211112121");
1677 \thirtyninechar("+")("1211121211");
1678 \thirtyninechar("$")("1212121111");
1679 \thirtyninechar("/")("1212111211");
1680 \thirtyninechar(".")("2211112111");
1681 \thirtyninechar( 37)("1112121211"); % percent
1682 \thirtyninechar( 32)("1221112111"); % space
1683 \thirtyninechar("A")("2111121121");
1684 \thirtyninechar("B")("1121121121");
1685 \thirtyninechar("C")("2121121111");
1686 \thirtyninechar("D")("1111221121");
1687 \thirtyninechar("E")("2111221111");
1688 \thirtyninechar("F")("1121221111");
1689 \thirtyninechar("G")("1111122121");
1690 \thirtyninechar("H")("2111122111");
1691 \thirtyninechar("I")("1121122111");
1692 \thirtyninechar("J")("1111222111");
1693 \thirtyninechar("K")("2111111221");
1694 \thirtyninechar("L")("1121111221");
1695 \thirtyninechar("M")("2121111211");
1696 \thirtyninechar("N")("1111211221");
1697 \thirtyninechar("O")("2111211211");
1698 \thirtyninechar("P")("1121211211");
1699 \thirtyninechar("Q")("1111112221");
1700 \thirtyninechar("R")("2111112211");
1701 \thirtyninechar("S")("1121112211");
1702 \thirtyninechar("T")("1111212211");
1703 \thirtyninechar("U")("2211111121");
1704 \thirtyninechar("V")("1221111121");
1705 \thirtyninechar("W")("2221111111");
1706 \thirtyninechar("X")("1211211121");
1707 \thirtyninechar("Y")("2211211111");
1708 \thirtyninechar("Z")("1221211111");
1709
1710 \end;
1711
1712 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1713 % % MetaFont Code for Code 39 ends here %
1714 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1715 %</code39mf>
1716 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1717 % % MetaFont Code for Code 128 starts here %
1718 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1719 %<*code128mf>
1720 %% Code 128, in Metafont mode
1721 %% This gives a raw font, that should be mapped properly
1722 %% so read the docs!
1723 %% Willadt 1997-08-17
1724
1725 mode_setup;
1726
1727 bheight#:=5mm#;
1728
1729 %% high res: .264 mm#
1730 %% med res: .33 mm#
1731 bwidth# :=.33 mm#;
1732
1733 designsize :=bheight#;
1734 font_slant :=0;
1735 font_normal_space :=11*bwidth#;
1736 font_extra_space :=0;
1737 font_normal_stretch:=0;
1738 font_normal_shrink :=0;
1739 font_quad :=11*bwidth#;
1740
1741 define_pixels(bheight, bwidth);
1742
1743 def CXXVIIIchar(expr charnum, spex) =
1744 numeric mywid, asval, i;
1745 mywid=0;
1746 % for i = 0 upto 8:
1747 % asval:=ASCII(substring(i,i+1) of spex);
1748 % exitif asval=-1;
1749 % asval:=asval-ASCII("0");
1750 % mywid:=mywid+asval;
1751 % endfor
1752 % beginchar(charnum, mywid*bwidth#,bheight#,0);
1753 beginchar(charnum, 11*bwidth#,bheight#,0);
1754 y1=y2=0;
1755 y3=y4=bheight;
1756 numeric myright,myleft,barweight,spcweight;
1757 myright:=0;myleft:=0;barweight:=0;spcweight:=0;
1758 for i=0 upto 8:
1759 asval:=ASCII(substring(i,i+1) of spex);
1760 exitif asval=-1;
1761 asval:=asval-ASCII("0");
1762 myright:=myright+asval*bwidth;
1763 if not odd (i):
1764 % check for typos
1765 % barweight:=barweight+asval;
1766 % actual drawing
1767 x1:=myleft-blacker;
1768 x4:=x1;
1769 x2:=myright+blacker;
1770 x3:=x2;
1771 fill (z1)--(z2)--(z3)--(z4)--cycle;
1772 % check for typos
1773 % else:
1774 % spcweight:=spcweight+asval;
1775 fi
1776 myleft:=myright;
1777 endfor;
1778 % check for typos
1779 % if not odd(spcweight): message "error in spc cnt";
1780 % fi
1781 % if odd(barweight): message "error in bar cnt";
1782 % fi
1783 endchar;
1784 enddef;
1785
1786 CXXVIIIchar(107,"212222"); % Ersatz fuer Null
1787 CXXVIIIchar( 0,"212222");
1788 CXXVIIIchar( 1,"222122");
1789 CXXVIIIchar( 2,"222221");
1790 CXXVIIIchar( 3,"121223");
1791 CXXVIIIchar( 4,"121322");
1792 CXXVIIIchar( 5,"131222");
1793 CXXVIIIchar( 6,"122213");
1794 CXXVIIIchar( 7,"122312");
1795 CXXVIIIchar( 8,"132212");
1796 CXXVIIIchar( 9,"221213");
1797 CXXVIIIchar( 10,"221312");
1798 CXXVIIIchar( 11,"231212");
1799 CXXVIIIchar( 12,"112232");
1800 CXXVIIIchar( 13,"122132");
1801 CXXVIIIchar( 14,"122231");
1802 CXXVIIIchar( 15,"113222");
1803 CXXVIIIchar( 16,"123122");
1804 CXXVIIIchar( 17,"123221");
1805 CXXVIIIchar( 18,"223211");
1806 CXXVIIIchar( 19,"221132");
1807 CXXVIIIchar( 20,"221231");
1808 CXXVIIIchar( 21,"213212");
1809 CXXVIIIchar( 22,"223112");
1810 CXXVIIIchar( 23,"312131");
1811 CXXVIIIchar( 24,"311222");
1812 CXXVIIIchar( 25,"321122");
1813 CXXVIIIchar( 26,"321221");
1814 CXXVIIIchar( 27,"312212");
1815 CXXVIIIchar( 28,"322112");
1816 CXXVIIIchar( 29,"322211");
1817 CXXVIIIchar( 30,"212123");
1818 CXXVIIIchar( 31,"212321");
1819 CXXVIIIchar( 32,"232121");
1820 CXXVIIIchar( 33,"111323");
1821 CXXVIIIchar( 34,"131123");
1822 CXXVIIIchar( 35,"131321");
1823 CXXVIIIchar( 36,"112313");
1824 CXXVIIIchar( 37,"132113");
1825 CXXVIIIchar( 38,"132311");
1826 CXXVIIIchar( 39,"211313");
1827 CXXVIIIchar( 40,"231113");
1828 CXXVIIIchar( 41,"231311");
1829 CXXVIIIchar( 42,"112133");
1830 CXXVIIIchar( 43,"112331");
1831 CXXVIIIchar( 44,"132131");
1832 CXXVIIIchar( 45,"113123");
1833 CXXVIIIchar( 46,"113321");
1834 CXXVIIIchar( 47,"133121");
1835 CXXVIIIchar( 48,"313121");
1836 CXXVIIIchar( 49,"211331");
1837 CXXVIIIchar( 50,"231131");
1838 CXXVIIIchar( 51,"213113");
1839 CXXVIIIchar( 52,"213311");
1840 CXXVIIIchar( 53,"213131");
1841 CXXVIIIchar( 54,"311123");
1842 CXXVIIIchar( 55,"311321");
1843 CXXVIIIchar( 56,"331121");
1844 CXXVIIIchar( 57,"312113");
1845 CXXVIIIchar( 58,"312311");
1846 CXXVIIIchar( 59,"332111");
1847 CXXVIIIchar( 60,"314111");
1848 CXXVIIIchar( 61,"221411");
1849 CXXVIIIchar( 62,"431111");
1850 CXXVIIIchar( 63,"111224");
1851 CXXVIIIchar( 64,"111422");
1852 CXXVIIIchar( 65,"121124");
1853 CXXVIIIchar( 66,"121421");
1854 CXXVIIIchar( 67,"141122");
1855 CXXVIIIchar( 68,"141221");
1856 CXXVIIIchar( 69,"112214");
1857 CXXVIIIchar( 70,"112412");
1858 CXXVIIIchar( 71,"122114");
1859 CXXVIIIchar( 72,"122411");
1860 CXXVIIIchar( 73,"142112");
1861 CXXVIIIchar( 74,"142211");
1862 CXXVIIIchar( 75,"241211");
1863 CXXVIIIchar( 76,"221114");
1864 CXXVIIIchar( 77,"413111");
1865 CXXVIIIchar( 78,"241112");
1866 CXXVIIIchar( 79,"134111");
1867 CXXVIIIchar( 80,"111242");
1868 CXXVIIIchar( 81,"121142");
1869 CXXVIIIchar( 82,"121241");
1870 CXXVIIIchar( 83,"114212");
1871 CXXVIIIchar( 84,"124112");
1872 CXXVIIIchar( 85,"124211");
1873 CXXVIIIchar( 86,"411212");
1874 CXXVIIIchar( 87,"421112");
1875 CXXVIIIchar( 88,"421211");
1876 CXXVIIIchar( 89,"212141");
1877 CXXVIIIchar( 90,"214121");
1878 CXXVIIIchar( 91,"412121");
1879 CXXVIIIchar( 92,"111143");
1880 CXXVIIIchar( 93,"111341");
1881 CXXVIIIchar( 94,"131141");
1882 CXXVIIIchar( 95,"114113");
1883 CXXVIIIchar( 96,"114311");
1884 CXXVIIIchar( 97,"411113");
1885 CXXVIIIchar( 98,"411311");
1886 CXXVIIIchar( 99,"113141");
1887 CXXVIIIchar(100,"114131");
1888 CXXVIIIchar(101,"311141");
1889 CXXVIIIchar(102,"411131");
1890 CXXVIIIchar(103,"211412");
1891 CXXVIIIchar(104,"211214");
1892 CXXVIIIchar(105,"211232");
1893 CXXVIIIchar(106,"2331112");
1894
1895 end;
1896 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1897 % % MetaFont Code for Code 128 ends here %
1898 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1899 %</code128mf>
1900 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1901 % % MetaFont Code for EAN starts here %
1902 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1903 %<*codeeanmf>
1904 %% Font for printing EAN Code
1905 %% For small sizes (on the Deskjet, < 1,0) you have to be
1906 %% very careful and test if the font is still machine readable.
1907 %% On write-black-printers, it may be necessary to reduce
1908 %% the width of black bars by fiddling with
1909 %% the definition of fb().
1910 %% For producing EAN Add-ons or codes with variable height,
1911 %% it would be a good idea to shorten the height of the bars and
1912 %% to leave the numbers out of the bars-definition, so that you
1913 %% could stack several bars above each other.
1914 %% Flexibility would increase, but---on the other hand---
1915 %% TeX macros for setting EAN code would become even more complicated.
1916 %
1917 %% Peter Willadt 1997, September, 21
1918 %
1919 % For more information about EAN-Codes, you may consult the Centrale
1920 % f\"ur Coorganisation in K\"oln, Germany, or one of the associated
1921 % organisations in your country. The complete EAN-Handbook costs
1922 % about a hundred german marks.
1923 %
1924 % Just some information:
1925 % EAN-Digits consist of seven elements that are either black or white.
1926 % Each element has the same width.
1927 % Fonts A, B, and C are differently coded.
1928 % The first half of the EAN-number is coded in fonts A and B, the second
1929 % half is coded in font C. The first digit of the EAN-number is not
1930 % directly coded but will be taken from the alternate uses of characters
1931 % from font A and font B for the first half.
1932 % This strange coding is a direct consequence of
1933 % the ancestry of the EAN-code---it is derived from the american UPC-code
1934 % (12 digits)---and there had to be a way of compatibly expanding the UPC.
1935 %
1936 % The first two digits of the EAN-number code the country of origin of
1937 % the product, the next five digits (mostly) code the manufacturer, the
1938 % remaining digits (with the exception of the last) code the product.
1939 % The last digit of the EAN-number is a checksum.
1940 % For In-House-Use, you may use EAN starting with 20 to 29.
1941 %
1942 % EAN numbers do not contain any qualifiers. From a number, you cannot say
1943 % which kind of product is coded, unless you contact the manufacturer.
1944 %
1945 % Eight digit EAN numbers consist of four digits from font A and four digits
1946 % from font C.
1947 %
1948 % UPC is EAN with the first digit equal to zero.
1949 %
1950 % Here is a table that shows which code to use for the digits 2 to 7
1951 % depending on the first digit.
1952 % The number on the right shows the first digit.
1953 % A zero in the array means to choose font A, a one means to choose font B.
1954 %
1955 % static UBYTE abtab[10][6]={
1956 % {0,0,0,0,0,0}, /* 0 */
1957 % {0,0,1,0,1,1}, /* 1 */
1958 % {0,0,1,1,0,1}, /* 2 */
1959 % {0,0,1,1,1,0}, /* 3 */
1960 % {0,1,0,0,1,1}, /* 4 */
1961 % {0,1,1,0,0,1}, /* 5 */
1962 % {0,1,1,1,0,0}, /* 6 */
1963 % {0,1,0,1,0,1}, /* 7 */
1964 % {0,1,0,1,1,0}, /* 8 */
1965 % {0,1,1,0,1,0} /* 9 */
1966 % };
1967 % This font is coded in a way that requires extensive preprocessing.
1968 % 0 to 9 yield the digits from 0 to 9
1969 % A to J yield the codes from charset A
1970 % a to j yield the codes from charset B
1971 % K to T yield the codes from charset C
1972 % + makes the start and stop sign and - the middle sign
1973 % So, to code the number 2099993098253, you have to write
1974 % {\eanfont2 +AJjjJd-KTSMPN+}. Please note that the last
1975 % digit is a checksum.
1976 % This font is free to be used without any further permission;
1977 % it comes with no warranty. I strongly recommend to test
1978 % the readability of barcodes before going into mass production.
1979 %
1980 % There should be a Perl routine delivered together with this font
1981 % that takes a TeX file and replaces EAN numbers by their encoded
1982 % equivalent. There also should be a file called EANDOC.TEX
1983 % that tells you more about that.
1984 %
1985 %% Author
1986 %% Peter Willadt
1987 %% 75177 Pforzheim
1988 %% Germany
1989 %% email: [email protected]
1990 %
1991
1992 mode_setup;
1993
1994 %% EAN size 1 (100%)
1995 %
1996 bheight#:=22.85mm#;
1997 bdepth#:=1.65mm#;
1998 bwidth#:=0.33mm#;
1999 digheight#:=2.75mm#;
2000 numgap#=1mm#;
2001 digdiam#=0.9pt#;
2002 lgap#:= bwidth#+0.5 digdiam#;
2003 totheight#=bheight#+digheight#+numgap#;
2004 ndheight#:=totheight#-bheight#-bdepth#;
2005 define_pixels(ndheight,digheight,numgap,lgap,bwidth);
2006 define_blacker_pixels(bheight,totheight,digdiam);
2007
2008 font_normal_space=7*bwidth#;
2009 font_size 10pt#;
2010
2011 def fb(expr posn) =
2012 x20:=(posn-1)*bwidth;
2013 x21:=x20;
2014 x22:=posn*bwidth;
2015 x23:=x22;
2016 y20:=y22:=digheight+numgap;
2017 y21:=y23:=h;
2018 fill z20--z21--z23--z22--cycle;
2019 enddef;
2020
2021 def klotz(expr posn) =
2022 x1:=(posn-1)*bwidth;x2:=posn*bwidth;
2023 x3:=x2;x4:=x1;
2024 y1:=y2:=ndheight;
2025 y3:=y4:=digheight+numgap;
2026 fill z1--z2--z3--z4--cycle;
2027 enddef;
2028
2029 def nuller =
2030 x1=0.5w;
2031 y1=digheight;
2032 x2=lgap;
2033 y2=0.8y1;
2034 x3=x2;
2035 y3-y4=y1-y2;
2036 y4=0;
2037 x4=x1;
2038 x5=w-x3;
2039 y5=y3;
2040 x6=x5;
2041 y6=y2;
2042 pickup pencircle scaled digdiam;
2043 draw z1..{down}z2--z3{down}..z4..{up}z5--z6{up}..cycle;
2044 enddef;
2045
2046 def einser =
2047 x1=x2=0.5w+lgap;
2048 x3=2*lgap;
2049 y1=0;
2050 y2=digheight;
2051 y3=0.8digheight;
2052 pickup pencircle scaled digdiam;
2053 draw z1--z2--z3;
2054 enddef;
2055
2056 def zweier =
2057 x1=w-lgap;
2058 x2=lgap;
2059 y1=y2=0;
2060 x3=x2;
2061 y3=0.15 digheight;
2062 x4=w-lgap;
2063 y4=0.6 digheight;
2064 x5=x4;
2065 y5=0.9 digheight;
2066 x6=0.5w;
2067 y6=digheight;
2068 x7=x2;
2069 y7=y5;
2070 pickup pencircle scaled digdiam;
2071 draw z1--z2{up}..z3..z4..z5..z6..z7;
2072 enddef;
2073
2074 def dreier =
2075 x1=lgap;
2076 w-x2=x1;
2077 y1=y2=digheight;
2078 x3=0.5w;
2079 y3=0.6digheight;
2080 y4=0.5y3;
2081 x4=x2;
2082 % y5=0.5digdiam;
2083 y5=0;
2084 x5=0.5w;
2085 x6=x1;
2086 y6=0.2 digheight;
2087 pickup pencircle scaled digdiam;
2088 draw z1--z2--z3{right}..z4..z5..z6;
2089 enddef;
2090
2091 def vierer =
2092 x1=0.6w;y1=digheight;
2093 x2=lgap;
2094 y2=0.3digheight;
2095 y3=y2;
2096 w-x3=x2;
2097 % w-x4=x4-x1;
2098 x4=0.5[x1,x3];
2099 x5=x4;
2100 y4=0.5digheight;
2101 y5=0;
2102 pickup pencircle scaled digdiam;
2103 draw z1--z2--z3;
2104 draw z4--z5;
2105 enddef;
2106
2107 def fuenfer =
2108 x2=lgap;
2109 x2=w-x1;
2110 y1=y2=digheight;
2111 x3=x2;
2112 y3=0.7digheight;
2113 x4=x1;
2114 y3-y4=y4;
2115 x5=x2;
2116 y5=0;
2117 pickup pencircle scaled digdiam;
2118 draw z1--z2--z3{right}..z4..{left}z5;
2119 enddef;
2120
2121 def sechser =
2122 x1=0.6w;
2123 y1=digheight;
2124 x2=lgap;
2125 x4=w-x2;
2126 % y2=y4=0.3digheight;
2127 y2=y4=0.5y5;
2128 x3=x5=0.5w;
2129 y3=0;
2130 % y5=0.6 digheight;
2131 y5=x4-x2;
2132 pickup pencircle scaled digdiam;
2133 draw z2..z3..z4..z5..cycle;
2134 draw z1..{down}z2;
2135 enddef;
2136 def siebener =
2137 x1=lgap;
2138 x2=w-x1;
2139 y1=y2=digheight;
2140 x3=x4=0.5w;
2141 y3=0.3digheight;
2142 y4=0;
2143 pickup pencircle scaled digdiam;
2144 draw z1--z2;
2145 draw z2..z3...z4;
2146 enddef;
2147 def achter =
2148 x1=x3=x5=0.5w;
2149 y1=digheight;
2150 y3=0.6digheight;
2151 y5=0;
2152 x2=w-x7;
2153 x4=w-x6;
2154 y2=y7=0.5[y1,y3];
2155 y4=y6=0.5[y3,y5];
2156 x2=1.5lgap;
2157 x4=w-lgap;
2158 pickup pencircle scaled digdiam;
2159 draw z1..z2..z3..z7..cycle;
2160 draw z3..z4..z5..z6..cycle;
2161 enddef;
2162 def neuner =
2163 x1=0.4w;
2164 y1=0;
2165 x2=w-lgap;
2166 x4=w-x2;
2167 % y2=y4=0.7digheight;
2168 y2=y4=0.5[y5,y3];
2169 x3=x5=0.5w;
2170 y3=digheight;
2171 y5=0.4 digheight;
2172 pickup pencircle scaled digdiam;
2173 draw z1..{up}z2;
2174 draw z2..z3..z4..z5..cycle;
2175 enddef;
2176 beginchar("+",3*bwidth#,totheight#,0); "Das Randzeichen";
2177 fb(1); fb(3);
2178 klotz(1);
2179 klotz(3);
2180 endchar;
2181 beginchar("-",5*bwidth#,totheight#,0); "Das Mittenzeichen";
2182 fb(2); fb(4);
2183 klotz(2);
2184 klotz(4);
2185 endchar;
2186
2187 beginchar("0",7*bwidth#,digheight#,0);
2188 nuller;
2189 endchar;
2190
2191 beginchar("1",7*bwidth#,digheight#,0);
2192 einser;
2193 endchar;
2194
2195 beginchar("2",7*bwidth#,digheight#,0);
2196 zweier;
2197 endchar;
2198
2199 beginchar("3",7*bwidth#,digheight#,0);
2200 dreier;
2201 endchar;
2202
2203 beginchar("4",7*bwidth#,digheight#,0);
2204 vierer;
2205 endchar;
2206
2207 beginchar("5",7*bwidth#,digheight#,0);
2208 fuenfer;
2209 endchar;
2210
2211 beginchar("6",7*bwidth#,digheight#,0);
2212 sechser;
2213 endchar;
2214
2215 beginchar("7",7*bwidth#,digheight#,0);
2216 siebener;
2217 endchar;
2218
2219 beginchar("8",7*bwidth#,digheight#,0);
2220 achter;
2221 endchar;
2222
2223 beginchar("9",7*bwidth#,digheight#,0);
2224 neuner;
2225 endchar;
2226
2227 % Zeichensatz A
2228
2229 beginchar("A",7*bwidth#,totheight#,0); "Die Null (A)";
2230 fb(4);fb(5);fb(7);
2231 nuller;
2232 endchar;
2233
2234 beginchar("B",7*bwidth#,totheight#,0); "Die Eins (A)";
2235 fb(3);fb(4);fb(7);
2236 einser;
2237 endchar;
2238
2239 beginchar("C",7*bwidth#,totheight#,0); "Die Zwei (A)";
2240 fb(3);fb(6);fb(7);
2241 zweier;
2242 endchar;
2243 beginchar("D",7*bwidth#,totheight#,0); "Die Drei (A)";
2244 fb(2);fb(3);fb(4);fb(5);fb(7);
2245 dreier;
2246 endchar;
2247 beginchar("E",7*bwidth#,totheight#,0); "Die Vier (A)";
2248 fb(2);fb(6);fb(7);
2249 vierer;
2250 endchar;
2251 beginchar("F",7*bwidth#,totheight#,0); "Die Fuenf (A)";
2252 fb(2);fb(3);fb(7);
2253 fuenfer;
2254 endchar;
2255 beginchar("G",7*bwidth#,totheight#,0); "Die Sechs (A)";
2256 fb(2);fb(4);fb(5);fb(6);fb(7);
2257 sechser;
2258 endchar;
2259 beginchar("H",7*bwidth#,totheight#,0); "Die Sieben (A)";
2260 fb(2);fb(3);fb(4);fb(6);fb(7);
2261 siebener;
2262 endchar;
2263
2264 beginchar("I",7*bwidth#,totheight#,0); "Die Acht (A)";
2265 fb(2);fb(3);fb(5);fb(6);fb(7);
2266 achter;
2267 endchar;
2268
2269 beginchar("J",7*bwidth#,totheight#,0); "Die Neun (A)";
2270 fb(4);fb(6);fb(7);
2271 neuner;
2272 endchar;
2273
2274 % Zeichensatz B
2275
2276 beginchar("a",7*bwidth#,totheight#,0); "Die Null (B)";
2277 fb(2);fb(5);fb(6);fb(7);
2278 nuller;
2279 endchar;
2280
2281 beginchar("b",7*bwidth#,totheight#,0); "Die Eins (B)";
2282 fb(2);fb(3);fb(6);fb(7);
2283 einser;
2284 endchar;
2285
2286 beginchar("c",7*bwidth#,totheight#,0); "Die Zwei (B)";
2287 fb(3);fb(4);fb(6);fb(7);
2288 zweier;
2289 endchar;
2290 beginchar("d",7*bwidth#,totheight#,0); "Die Drei (B)";
2291 fb(2);fb(7);
2292 dreier;
2293 endchar;
2294 beginchar("e",7*bwidth#,totheight#,0); "Die Vier (B)";
2295 fb(3);fb(4);fb(5);fb(7);
2296 vierer;
2297 endchar;
2298 beginchar("f",7*bwidth#,totheight#,0); "Die Fuenf (B)";
2299 fb(2);fb(3);fb(4);fb(7);
2300 fuenfer;
2301 endchar;
2302 beginchar("g",7*bwidth#,totheight#,0); "Die Sechs (B)";
2303 fb(5);fb(7);
2304 sechser;
2305 endchar;
2306 beginchar("h",7*bwidth#,totheight#,0); "Die Sieben (B)";
2307 fb(3);fb(7);
2308 siebener;
2309 endchar;
2310
2311 beginchar("i",7*bwidth#,totheight#,0); "Die Acht (B)";
2312 fb(4);fb(7);
2313 achter;
2314 endchar;
2315
2316 beginchar("j",7*bwidth#,totheight#,0); "Die Neun (B)";
2317 fb(3);fb(5);fb(6);fb(7);
2318 neuner;
2319 endchar;
2320
2321 % Zeichensatz C
2322
2323 beginchar("K",7*bwidth#,totheight#,0); "Die Null (C)";
2324 fb(1);fb(2);fb(3);fb(6);
2325 nuller;
2326 endchar;
2327
2328 beginchar("L",7*bwidth#,totheight#,0); "Die Eins (C)";
2329 fb(1);fb(2);fb(5);fb(6);
2330 einser;
2331 endchar;
2332
2333 beginchar("M",7*bwidth#,totheight#,0); "Die Zwei (C)";
2334 fb(1);fb(2);fb(4);fb(5);
2335 zweier;
2336 endchar;
2337 beginchar("N",7*bwidth#,totheight#,0); "Die Drei (C)";
2338 fb(1);fb(6);
2339 dreier;
2340 endchar;
2341 beginchar("O",7*bwidth#,totheight#,0); "Die Vier (C)";
2342 fb(1);fb(3);fb(4);fb(5);
2343 vierer;
2344 endchar;
2345 beginchar("P",7*bwidth#,totheight#,0); "Die Fuenf (C)";
2346 fb(1);fb(4);fb(5);fb(6);
2347 fuenfer;
2348 endchar;
2349 beginchar("Q",7*bwidth#,totheight#,0); "Die Sechs (C)";
2350 fb(1);fb(3);
2351 sechser;
2352 endchar;
2353 beginchar("R",7*bwidth#,totheight#,0); "Die Sieben (C)";
2354 fb(1);fb(5);
2355 siebener;
2356 endchar;
2357
2358 beginchar("S",7*bwidth#,totheight#,0); "Die Acht (C)";
2359 fb(1);fb(4);
2360 achter;
2361 endchar;
2362
2363 beginchar("T",7*bwidth#,totheight#,0); "Die Neun (C)";
2364 fb(1);fb(2);fb(3);fb(5);
2365 neuner;
2366 endchar;
2367
2368 end;
2369 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2370 % % MetaFont Code for EAN ends here %
2371 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2372 %</codeeanmf>
2373 %<*wlcr39mf>
2374 % Code 39, in Metafont mode
2375 % $90^0$ rotated to the right,
2376 % make Barcodes run down instead of across.
2377 % Willadt 1998-04-28
2378 mode_setup;
2379
2380 bwidth#:=5mm#;
2381
2382 % high res .2 mm,
2383 % med res .3 mm,
2384 % lo res .4 mm.
2385
2386 bheight# :=.3mm#;
2387
2388 designsize :=13*bheight#;
2389 font_slant :=0;
2390 font_normal_space :=bwidth#;
2391 font_extra_space :=0;
2392 font_normal_stretch:=0;
2393 font_normal_shrink :=0;
2394 font_quad :=bwidth#;
2395
2396 define_pixels(bheight, bwidth);
2397
2398 def thirtyninechar(expr charnum, spex) =
2399 beginchar(charnum, bwidth#,12*bheight#,bheight#);
2400 numeric mytop,mybot;
2401 numeric asval, i;
2402 mytop:=12*bheight;mybot:=mytop;
2403 x1=x2=0;x3=x4=bwidth;
2404 for i=0 upto 11:
2405 asval:=ASCII(substring(i,i+1) of spex);
2406 exitif asval=-1;
2407 asval:=asval-ASCII("0");
2408 mybot:=mybot-asval*bheight;
2409 if not odd (i):
2410 % actual drawing
2411 y1:=mytop+blacker;
2412 y4:=y1;
2413 y2:=mybot-blacker;
2414 y3:=y2;
2415 fill (z1)--(z2)--(z3)--(z4)--cycle;
2416 fi
2417 mytop:=mybot;
2418 endfor;
2419 endchar;
2420 enddef;
2421
2422 \thirtyninechar("0")("1112212111");
2423 \thirtyninechar("1")("2112111121");
2424 \thirtyninechar("2")("1122111121");
2425 \thirtyninechar("3")("2122111111");
2426 \thirtyninechar("4")("1112211121");
2427 \thirtyninechar("5")("2112211111");
2428 \thirtyninechar("6")("1122211111");
2429 \thirtyninechar("7")("1112112121");
2430 \thirtyninechar("8")("2112112111");
2431 \thirtyninechar("9")("1122112111");
2432 \thirtyninechar( 64)("1211212111"); % start = @
2433 \thirtyninechar("-")("1211112121");
2434 \thirtyninechar("+")("1211121211");
2435 \thirtyninechar("$")("1212121111");
2436 \thirtyninechar("/")("1212111211");
2437 \thirtyninechar(".")("2211112111");
2438 \thirtyninechar( 37)("1112121211"); % percent
2439 \thirtyninechar( 32)("1221112111"); % space
2440 \thirtyninechar("A")("2111121121");
2441 \thirtyninechar("B")("1121121121");
2442 \thirtyninechar("C")("2121121111");
2443 \thirtyninechar("D")("1111221121");
2444 \thirtyninechar("E")("2111221111");
2445 \thirtyninechar("F")("1121221111");
2446 \thirtyninechar("G")("1111122121");
2447 \thirtyninechar("H")("2111122111");
2448 \thirtyninechar("I")("1121122111");
2449 \thirtyninechar("J")("1111222111");
2450 \thirtyninechar("K")("2111111221");
2451 \thirtyninechar("L")("1121111221");
2452 \thirtyninechar("M")("2121111211");
2453 \thirtyninechar("N")("1111211221");
2454 \thirtyninechar("O")("2111211211");
2455 \thirtyninechar("P")("1121211211");
2456 \thirtyninechar("Q")("1111112221");
2457 \thirtyninechar("R")("2111112211");
2458 \thirtyninechar("S")("1121112211");
2459 \thirtyninechar("T")("1111212211");
2460 \thirtyninechar("U")("2211111121");
2461 \thirtyninechar("V")("1221111121");
2462 \thirtyninechar("W")("2221111111");
2463 \thirtyninechar("X")("1211211121");
2464 \thirtyninechar("Y")("2211211111");
2465 \thirtyninechar("Z")("1221211111");
2466
2467 \end;
2468 %</wlcr39mf>
2469 %<*code93mf>
2470 % not complete, yet
2471 %% Code 93 in Metafont format
2472 %% Peter Willadt 1998-04-21
2473 %% For copyright and the like see the documentation
2474 %% to the barcode package, from which this file is part of.
2475 %% If you received only this file,
2476 %% then maybe someone fooled you.
2477 %%
2478 %% Code 93 requires one or two check digits.
2479 %% These check digtis are calculated using a weighted mod 11-checksum.
2480 %% You have to see the docs.
2481 %% Start and stop chars are mapped to < and >, respectively.
2482 %% codeable are 0--9 , A-Z, -,+, space, dot, $, /, and percent.
2483 %% To print full ascii, ordinary characters have to be preceeded with
2484 %% on of four shift characters. Thes shift characters are
2485 %% ($) mapped to =
2486 %% (%) mapped to [
2487 %% (/) mapped to |
2488 %% (+) mapped to ]
2489
2490 mode_setup;
2491
2492 bheight#:=5mm#;
2493
2494 % high res: .264 mm#
2495 % med res: .33 mm#
2496 bwidth# :=.33 mm#;
2497
2498 designsize :=bheight#;
2499 font_slant :=0;
2500 font_normal_space :=9*bwidth#;
2501 font_extra_space :=0;
2502 font_normal_stretch:=0;
2503 font_normal_shrink :=0;
2504 font_quad :=10*bwidth#;
2505
2506 define_pixels(bheight, bwidth);
2507
2508 def CODExciiichar(expr charnum, spex) =
2509 numeric mywid, asval, i;
2510 mywid=0;
2511 for i= 0 upto 5:
2512 asval:=ASCII(substring(i,i+1) of spex);
2513 asval:=asval-ASCII("0");
2514 mywid:=mywid+asval;
2515 endfor;
2516 beginchar(charnum, mywid*bwidth#,bheight#,0);
2517 y1=y2=0;
2518 y3=y4=bheight;
2519 numeric myright,myleft,barweight,spcweight;
2520 myright:=0;myleft:=0;barweight:=0;spcweight:=0;
2521 for i=0 upto 5:
2522 asval:=ASCII(substring(i,i+1) of spex);
2523 asval:=asval-ASCII("0");
2524 myright:=myright+asval*bwidth;
2525 if not odd (i):
2526 % actual drawing
2527 x1:=myleft-blacker;
2528 x4:=x1;
2529 x2:=myright+blacker;
2530 x3:=x2;
2531 fill (z1)--(z2)--(z3)--(z4)--cycle;
2532 fi
2533 myleft:=myright;
2534 endfor;
2535 endchar;
2536 enddef;
2537
2538 CODExciiichar("0","131112");
2539 CODExciiichar("1","111213");
2540 CODExciiichar("2","111312");
2541 CODExciiichar("3","111411");
2542 CODExciiichar("4","121113");
2543 CODExciiichar("5","121212");
2544 CODExciiichar("6","121311");
2545 CODExciiichar("7","111114");
2546 CODExciiichar("8","131211");
2547 CODExciiichar("9","141111");
2548 CODExciiichar("A","211113");
2549 CODExciiichar("B","211212");
2550 CODExciiichar("C","211311");
2551 CODExciiichar("D","221112");
2552 CODExciiichar("E","221211");
2553 CODExciiichar("F","231111");
2554 CODExciiichar("G","112113");
2555 CODExciiichar("H","112212");
2556 CODExciiichar("I","112311");
2557 CODExciiichar("J","122112");
2558 CODExciiichar("K","132111");
2559 CODExciiichar("L","111123");
2560 CODExciiichar("M","111222");
2561 CODExciiichar("N","111321");
2562 CODExciiichar("O","121122");
2563 CODExciiichar("P","131121");
2564 CODExciiichar("Q","212112");
2565 CODExciiichar("R","212211");
2566 CODExciiichar("S","211122");
2567 CODExciiichar("T","211221");
2568 CODExciiichar("U","221121");
2569 CODExciiichar("V","222111");
2570 CODExciiichar("W","112122");
2571 CODExciiichar("X","112221");
2572 CODExciiichar("Y","122121");
2573 CODExciiichar("Z","123111");
2574 CODExciiichar("-","121131");
2575 CODExciiichar(".","311112");
2576 CODExciiichar( 32,"311211");% space
2577 CODExciiichar( 36,"321111");% dollar
2578 CODExciiichar("/","112131");
2579 CODExciiichar("+","113121");
2580 CODExciiichar( 37,"211131");% percent
2581 % % the four escape characters
2582 CODExciiichar("(","121221");% ought to be ($)
2583 CODExciiichar(")","312111");% ought to be (%)
2584 CODExciiichar("[","311121");% ought to be (/)
2585 CODExciiichar("]","122211");% ought to be (+)
2586 CODExciiichar("<","111141");% start sign
2587 CODExciiichar(">","1111411");% stop sign has extra bar
2588
2589 end;
2590 %</code93mf>