summaryrefslogtreecommitdiff
path: root/tex/context/base/mkxl/libs-imp-zint.mkxl
blob: 9905e047095fb8030f0f1d85cefe5b06bcf37794 (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
%D \module
%D   [       file=m-zint,
%D        version=2010.12.07,
%D          title=\CONTEXT\ Extra Modules,
%D       subtitle=Zint Barcode Generator,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

%D Using \type {zint} seems to be the easiest way to generate (PDF417) barcodes so
%D therefore we now have this module. There are proper (also windows) binaries at:
%D
%D \starttyping
%D http://www.zint.org.uk
%D \stoptyping
%D
%D There is a bit more code than needed as we want to be able to feed names.
%D
%D % e:\tex-context\tex\texmf-win64\bin\lib\luametatex\zint\libzint.dll

% \enabletrackers[*res*]

\registerctxluafile{libs-imp-zint}{autosuffix}

\unprotect

\definefont[usedzintfont][dejavusansmono at 10bp]

\permanent\protected\def\barcode[#1]% [alternative=,text=]
  {\bgroup
   \usedzintfont
   \getdummyparameters
     [\c!alternative=,\c!text=,\c!option=,#1]%
   \scale
     [#1]%
     {\clf_zint
         code   {\dummyparameter\c!alternative}
         text   {\dummyparameter\c!text}
         option {\dummyparameter\c!option}
      \relax}%
   \egroup}

\protect

\continueifinputfile{libs-imp-zint.mkxl}

\starttext

\dontcomplain

% \dorecurse{1}{
%     \startTEXpage
%         \barcode[alternative=PDF417,text={Hans Hagen}]%
%         \blank
%         \barcode[alternative=PDF417,text={Ton Otten}]%
%         \blank
%         \barcode[alternative=ISBN,text=9789490688011]%
%         \blank
%         \barcode[alternative=isbn,text=9789490688011,width=3cm]%
%         \blank
%         \dontleavehmode
%         \barcode[alternative=qr code,text={This is ConTeXt MKIV : #1}]
%         \barcode[alternative=qr code,text={This is ConTeXt LMTX}]
%         \barcode[alternative=qr code,text={\cldloadfile{tufte}},width=3cm]
%         \blank
%         \barcode[alternative=datamatrix,text=whatever,width=3cm,option=square]
%         \scale[width=3cm,height=3cm]{\barcode[alternative=datamatrix,text=whatever,width=3cm,option=square]}
%         \barcode[alternative=datamatrix,text={helloworld}]
%         \barcode[alternative=datamatrix,text={hello world}]
%     \stopTEXpage
% }

    \startTEXpage
        \startluacode
            for i=1,100 do
                context.dontleavehmode()
                context.barcode {
                    alternative = "datamatrix",
                    text        = string.rep("!",i),
                }
                context.space()
                context.allowbreak()
            end
        \stopluacode
    \stopTEXpage

    \startTEXpage
        \startluacode
            for i=1,100 do
                context.dontleavehmode()
                context.barcode {
                    alternative = "datamatrix",
                    text        = string.rep("!",i),
                    option      = "square",
                }
                context.space()
                context.allowbreak()
            end
        \stopluacode
    \stopTEXpage

        \startluacode
            for i=1,25 do
                context.startTEXpage()
                context.dontleavehmode()
                context(i)
                context.space()
                context.barcode {
                    alternative = "datamatrix",
                    text        = string.rep("!",i),
                }
                context.space()
                context.barcode {
                    alternative = "datamatrix",
                    text        = string.rep("!",i),
                    option      = "square",
                }
                context.stopTEXpage()
            end
        \stopluacode
\stoptext