summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/barcodes/barcodes.sty
blob: beb2b3a6e274b8ceceea7e067ae876e95315c94f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
%%
%% This is file `barcodes.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% barcodes.dtx  (with options: `bcsty')
%% As this is a generated file, you may perhaps not want to edit it.
%% This file belongs to the barcode package.
%% It may be of no great use without the rest of the barcode package.
%% \CharacterTable
%%  {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
%%   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
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Options for using barcodes                             %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% documented in bcfaq.tex                                %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% itf stuff
%% general
\font\xlix=wlc39 scaled 2000
\font\fntxciii=wlc93 scaled 2000
\font\itf=wlitf  scaled 2000
\font\cdb=wlcdb  scaled 2000
\font\eanfont=wlean scaled 1200
\font\fntcxx=wlc128 scaled \magstep3
%% barcodes with depth
\def\bcbox#1{\lower3pt\hbox{\itf +#1-}}
%% barcodes made taller
\newbox\bsavebox
\newdimen\bcboxdepth
\bcboxdepth=4pt
\def\bdbox#1{\setbox\bsavebox\hbox{\itf +#1-}
\vbox{\hsize=\wd\bsavebox\offinterlineskip%
\copy\bsavebox%
\vskip-\ht\bsavebox\vskip\bcboxdepth%
\box\bsavebox\vskip-\bcboxdepth}}
\def\bebox#1{\setbox\bsavebox\hbox{\itf +#1-}
\vbox{\hsize=\wd\bsavebox\offinterlineskip%
\copy\bsavebox%
\copy\bsavebox%
\vskip-\ht\bsavebox\vskip\bcboxdepth%
\box\bsavebox\vskip-\bcboxdepth}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Code 128 stuff
\font\fntcxx=wlc128 scaled \magstep3
\def\XCIII#1{\bgroup\fntxciii #1}
\def\CXXVIII{\bgroup\fntcxx\let\next\hexchar\next}
\def\cxxviii{\message{OOPS, use codean.pl}}
\def\hexchar#1#2{\if#1@
            \global\let\next\egroup
            \else\char"#1#2\fi\next}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Code 11 stuff
\font\codxifnt=wlc11 scaled\magstep2
%% relies on counters \cha and \chb defined below
\newif\ifcodexichecksumk
\codexichecksumkfalse
\makeatletter
\def\check@xichar{%
\ifcodexichecksumk%
{\count0=\cha\count1=\count0\divide\count1by11%
 \multiply\count1by11\advance\count0by-\count1%
 \ifnum10=\count0-\else\relax\the\count0\fi%
 \global\advance\chb by\count0\global\advance\cha by\chb%
}\fi
\chb=\cha\divide\chb by11%
\multiply\chb by11\advance\cha by-\chb%
\ifnum10=\cha-\else\the\cha\fi%
}
\def\csumxi#1{%
\if @#1%
\let\next\check@xichar%
\else \if-#1\advance\chb by10%
\else\advance\chb by#1%
\fi%
\advance\cha by\chb%
#1%
\fi%
\next%
}
\makeatother
\def\codxi#1{{
\codxifnt
\cha=0\chb=0%
@\let\next\csumxi\expandafter\expandafter\expandafter\csumxi#1@@
}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\font\codtnfnt=wlc39 scaled\magstep2
\def\codxxxix#1{{\codtnfnt @#1@}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% EAN stuff
%% this code comes from Kalvis M. Jansons
%% eMail: <kalvis@math.ucl.ac.uk>
%%
\font\eanfont=WLEAN scaled 2000
\def\ean#1{\vbox{\vskip20pt\eanfont#1\vskip20pt}}
\newcount\num
\def\a#1{\num=#1 \advance\num by `A \char\num}
\def\b#1{\num=#1 \advance\num by `a \char\num}
\def\c#1{\num=#1 \advance\num by `K \char\num}
\def\C#1#2#3#4#5#6{\c#1\c#2\c#3\c#4\c#5\c#6}
\def\A#1#2#3#4#5#6#7{\ifcase #7
{\a#1\a#2\a#3\a#4\a#5\a#6}%
\or {\a#1\a#2\b#3\a#4\b#5\b#6}%
\or {\a#1\a#2\b#3\b#4\a#5\b#6}%
\or {\a#1\a#2\b#3\b#4\b#5\a#6}%
\or {\a#1\b#2\a#3\a#4\b#5\b#6}%
\or {\a#1\b#2\b#3\a#4\a#5\b#6}%
\or {\a#1\b#2\b#3\b#4\a#5\a#6}%
\or {\a#1\b#2\a#3\b#4\a#5\b#6}%
\or {\a#1\b#2\a#3\b#4\b#5\a#6}%
\or {\a#1\b#2\b#3\a#4\b#5\a#6}%
\fi}
\newcount\cha
\newcount\chb
\makeatletter
\long\def\for{\@for}
\makeatother
\gdef\mysix#1#2#3#4#5#6{,#1#2,#3#4,#5#6}
\gdef\mywork#1#2{\advance\cha by #1 \advance\chb by #2}
\gdef\barch#1.#2.#3.{
\xdef\mylist{0#1\mysix#2\mysix#3}
\cha=0
\chb=0
\for \x:=\mylist\do{\expandafter\mywork\x}
\multiply\cha by 3
\advance\chb by \cha
\cha=\chb
\divide\cha by 10
\multiply\cha by -10
\advance\chb by \cha}
\def\bar#1.#2.#3.{\barch#1.#2.#3.
\ifnum\chb>0 #1#2#3 has a bad check sum!\\[20pt]
\else \ean{#1 +\A#2#1-\C#3+}\fi}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\endinput
%%
%% End of file `barcodes.sty'.