Debian Codegraph @

texmf-dist/tex/generic/pst-barcode/pst-barcode.tex

raw
1 %% $Id: pst-barcode.tex 1251 2026-05-18 05:21:03Z herbert $
2 %%
3 %% This is file `pst-barcode.tex',
4 %%
5 %% IMPORTANT NOTICE:
6 %%
7 %% Package `pst-barcode.tex'
8 %%
9 %% Terry Burton <tez _at_ terryburton.co.uk>
10 %% Herbert Voss <hvoss _at_ tug.org>
11 %%
12 %% This program can be redistributed and/or modified under the terms
13 %% of the LaTeX Project Public License Distributed from CTAN archives
14 %% in directory macros/latex/base/lppl.txt.
15 %%
16 %% DESCRIPTION:
17 %% `pst-barcode' is a PSTricks package to draw barcodes
18 %%
19 \csname PSTBarcodeLoaded\endcsname
20 \let\PSTBarcodeLoaded\endinput
21 \ifx\PSTricksLoaded\endinput\else\input pstricks.tex\fi
22 %
23 \def\fileversion{0.23}
24 \def\filedate{2026/05/18}
25 \message{`PST-barcode' v\fileversion, \filedate\space (tb,hv)}
26 %
27 \edef\PstAtCode{\the\catcode`\@} \catcode`\@=11\relax
28 \ifx\PSTXKeyLoaded\endinput\else\input pst-xkey \fi
29 \pst@addfams{pst-barcode}
30 %\pstheader{pst-barcode.fonts}
31 \pstheader{pst-barcode.pro}
32 %
33 \@ifundefined{marginnote}{\RequirePackage{marginnote}}{}
34 %
35 \newsavebox\QR@box
36 \define@key[psset]{pst-barcode}{fontstyle}[\small]{\def\pst@fontstyle{#1}}
37 \define@key[psset]{pst-barcode}{transx}[0]{\pst@getlength{#1}\psk@barcode@transx}
38 \define@key[psset]{pst-barcode}{transy}[0]{\pst@getlength{#1}\psk@barcode@transy}
39 \define@key[psset]{pst-barcode}{scalex}[1]{\def\psk@barcode@scalex{#1}}
40 \define@key[psset]{pst-barcode}{scaley}[1]{\def\psk@barcode@scaley{#1}}
41 \define@key[psset]{pst-barcode}{rotate}[0]{\pst@getangle{#1}\psk@barcode@rotate}
42 \define@boolkey[psset]{pst-barcode}[Pst@]{file}[true]{}
43 \psset[pst-barcode]{transx=0,transy=0,scalex=1,scaley=1,rotate=0,file=false,
44 fontstyle=\small\ttfamily}
45 %
46 \def\psbarcode{\pst@object{psbarcode}}
47 \def\psbarcode@i#1#2#3{%
48 \begin@SpecialObj
49 \addto@pscode{
50 gsave
51 \psk@barcode@rotate\space
52 \psk@barcode@scalex\space \psk@barcode@scaley\space
53 \psk@barcode@transx\space \psk@barcode@transy\space
54 translate scale rotate
55 0 0 moveto
56 \ifPst@file
57 /File 10000 string def
58 /ExternalFile { (#1)(r) file } def
59 ExternalFile File readstring
60 ExternalFile closefile
61 File 0 rightTrim % strip the /000 on the right
62 % pstack
63 \else (#1) \fi
64 (#2) /#3 /uk.co.terryburton.bwipp findresource exec
65 grestore
66 }%
67 \end@SpecialObj%
68 \ignorespaces%
69 }
70 %
71 %
72 \def\short@url#1/#2\@nil{\ifx\relax#2\relax #1\else\short@url#2\@nil\fi}
73 \def\QR{\@ifnextchar[\QR@i{\QR@i[0.5]}}
74 \def\QR@i[#1]{\@ifnextchar<{\QR@ii[#1]}{\QR@ii[#1]<>}}
75 \def\QR@ii[#1]<#2>#3{%
76 \marginnote{\pspicture(#1in,#1in)
77 \expandafter\psbarcode\expandafter{#2}{width=#1 height=#1}{qrcode}
78 \endpspicture
79 \newline\noindent
80 \ifx\relax#2\relax
81 \sbox\QR@box{\expandafter\pst@fontstyle\short@url#3/\@nil}% Speichere Kurz-URL in \QRbox
82 \else
83 \sbox\QR@box{#2}%
84 \fi
85 \ifdim\wd\QR@box>#1in\resizebox{#1in}{\ht\QR@box}{\usebox\QR@box}\else\usebox\QR@box\fi}}
86 %
87 \catcode`\@=\PstAtCode\relax
88 %
89 %% END: pst-barcode.tex
90 \endinput