Subversion Repositories Scribus

Compare Revisions

Ignore whitespace Rev 4785 → Rev 4784

/branches/Version13x/Scribus/scribus/plugins/barcodegenerator/barcode.ps
4,10 → 4,10
%%EndComments
%%EndProlog
 
% Barcode Writer in Pure PostScript - Version 2006-03-02
% Barcode Writer in Pure PostScript - Version 2006-01-17
% http://www.terryburton.co.uk/barcodewriter/
%
% Copyright (c) 2006 Terry Burton - tez@terryburton.co.uk
% Copyright (c) 2005 Terry Burton - tez@terryburton.co.uk
%
% Permission is hereby granted, free of charge, to any
% person obtaining a copy of this software and associated
159,7 → 159,7
% Return the arguments
/retval 4 dict def
retval (sbs) mark sbs {48 sub} forall ] put
retval (sbs) sbs put
includetext {
retval (bhs) [height height 12{height .075 sub}repeat height height 12{height .075 sub}repeat height height] put
retval (bbs) [0 0 12{.075}repeat 0 0 12{.075}repeat 0 0] put
170,7 → 170,6
} ifelse
retval (opt) useropts put
retval (guardrightpos) 10 put
retval (borderbottom) 5 put
retval
end
256,7 → 255,7
 
% Return the arguments
/retval 4 dict def
retval (sbs) mark sbs {48 sub} forall ] put
retval (sbs) sbs put
includetext {
retval (bhs) [height height 8{height .075 sub}repeat height height 8{height .075 sub}repeat height height] put
retval (bbs) [0 0 8{.075}repeat 0 0 8{.075}repeat 0 0] put
268,7 → 267,6
retval (opt) useropts put
retval (guardleftpos) 10 put
retval (guardrightpos) 10 put
retval (borderbottom) 5 put
retval
 
end
383,7 → 381,7
 
% Return the arguments
/retval 4 dict def
retval (sbs) mark sbs {48 sub} forall ] put
retval (sbs) sbs put
includetext {
retval (bhs) [4{height}repeat 10{height .075 sub}repeat height height 10{height .075 sub}repeat 5{height}repeat] put
retval (bbs) [0 0 0 0 10{.075}repeat 0 0 10{.075}repeat 0 0 0 0 0] put
393,7 → 391,6
retval (bbs) [31{0}repeat] put
} ifelse
retval (opt) useropts put
retval (borderbottom) 5 put
retval
 
end
518,7 → 515,7
 
% Return the arguments
/retval 4 dict def
retval (sbs) mark sbs {48 sub} forall ] put
retval (sbs) sbs put
includetext {
retval (bhs) [height height 12{height .075 sub}repeat height height height] put
retval (bbs) [0 0 12{.075}repeat 0 0 0] put
528,7 → 525,6
retval (bbs) [17{0}repeat] put
} ifelse
retval (opt) useropts put
retval (borderbottom) 5 put
retval
 
end
632,7 → 628,7
 
% Return the arguments
/retval 4 dict def
retval (sbs) mark sbs {48 sub} forall ] put
retval (sbs) sbs put
retval (bhs) [16{height}repeat] put
retval (bbs) [16{0}repeat] put
includetext {
641,7 → 637,6
retval (opt) useropts put
retval (guardrightpos) 10 put
retval (guardrightypos) textpos 4 add put
retval (bordertop) 10 put
retval
 
end
730,7 → 725,7
 
% Return the arguments
/retval 4 dict def
retval (sbs) mark sbs {48 sub} forall ] put
retval (sbs) sbs put
retval (bhs) [12{height}repeat] put
retval (bbs) [12{0}repeat] put
includetext {
739,7 → 734,6
retval (opt) useropts put
retval (guardrightpos) 10 put
retval (guardrightypos) textpos 4 add put
retval (bordertop) 10 put
retval
 
end
966,7 → 960,7
 
% Return the arguments
/retval 1 dict def
retval (sbs) mark sbs {48 sub} forall ] put
retval (sbs) sbs put
retval (bhs) [sbs length 1 add 2 idiv {height} repeat] put
retval (bbs) [sbs length 1 add 2 idiv {0} repeat] put
includetext {
1069,10 → 1063,10
sbs barlen 10 mul 10 add encs 43 get putinterval
txt barlen 1 add [(*) barlen 1 add 16 mul textpos textfont textsize] put
} ifelse
 
% Return the arguments
/retval 2 dict def
retval (sbs) mark sbs {48 sub} forall ] put
retval (sbs) sbs put
retval (bhs) [sbs length 1 add 2 idiv {height} repeat] put
retval (bbs) [sbs length 1 add 2 idiv {0} repeat] put
includetext {
1186,7 → 1180,7
 
% Return the arguments
/retval 1 dict def
retval (sbs) mark sbs {48 sub} forall ] put
retval (sbs) sbs put
retval (bhs) [sbs length 1 add 2 idiv {height} repeat] put
retval (bbs) [sbs length 1 add 2 idiv {0} repeat] put
includetext {
1315,7 → 1309,7
 
% Return the arguments
/retval 1 dict def
retval (sbs) mark sbs {48 sub} forall ] put
retval (sbs) sbs put
retval (bhs) [sbs length 1 add 2 idiv {height} repeat] put
retval (bbs) [sbs length 1 add 2 idiv {0} repeat] put
includetext {
1418,7 → 1412,7
% Return the arguments
/retval 1 dict def
retval (sbs) mark sbs {48 sub} forall ] put
retval (sbs) sbs put
retval (bhs) [sbs length 1 add 2 idiv {height} repeat] put
retval (bbs) [sbs length 1 add 2 idiv {0} repeat] put
includetext {
1543,7 → 1537,7
 
% Return the arguments
/retval 1 dict def
retval (sbs) mark sbs {48 sub} forall ] put
retval (sbs) sbs put
retval (bhs) [sbs length 1 add 2 idiv {height} repeat] put
retval (bbs) [sbs length 1 add 2 idiv {0} repeat] put
includetext {
1657,7 → 1651,7
 
% Return the arguments
/retval 1 dict def
retval (sbs) mark sbs {48 sub} forall ] put
retval (sbs) sbs put
retval (bhs) [sbs length 1 add 2 idiv {height} repeat] put
retval (bbs) [sbs length 1 add 2 idiv {0} repeat] put
includetext {
1772,9 → 1766,9
/retval 1 dict def
retval (bhs) bhs put
retval (bbs) [bhs length {0} repeat] put
/sbs bhs length 2 mul 1 sub array def
/sbs bhs length 2 mul 1 sub string def
0 1 sbs length 1 sub {
sbs exch 2 put % Fill with 2s
sbs exch 50 put % Fill with 2s
} for
retval (sbs) sbs put
includetext {
1892,9 → 1886,9
/retval 4 dict def
retval (bbs) bbs put
retval (bhs) bhs put
/sbs bhs length 2 mul 1 sub array def
/sbs bhs length 2 mul 1 sub string def
0 1 sbs length 1 sub {
sbs exch 2 put % Fill with 2s
sbs exch 50 put % Fill with 2s
} for
retval (sbs) sbs put
includetext {
2084,9 → 2078,9
/retval 4 dict def
retval (bbs) bbs put
retval (bhs) bhs put
/sbs bhs length 2 mul 1 sub array def
/sbs bhs length 2 mul 1 sub string def
0 1 sbs length 1 sub {
sbs exch 2 put % Fill with 2s
sbs exch 50 put % Fill with 2s
} for
retval (sbs) sbs put
includetext {
2183,9 → 2177,9
/retval 4 dict def
retval (bbs) bbs put
retval (bhs) bhs put
/sbs bhs length 2 mul 1 sub array def
/sbs bhs length 2 mul 1 sub string def
0 1 sbs length 1 sub {
sbs exch 2 put % Fill with 2s
sbs exch 50 put % Fill with 2s
} for
retval (sbs) sbs put
includetext {
2286,7 → 2280,7
 
% Return the arguments
/retval 1 dict def
retval (sbs) mark sbs {48 sub} forall ] put
retval (sbs) sbs put
retval (bhs) [sbs length 1 add 2 idiv {height} repeat] put
retval (bbs) [sbs length 1 add 2 idiv {0} repeat] put
includetext {
2404,7 → 2398,7
 
% Return the arguments
/retval 1 dict def
retval (sbs) mark sbs {48 sub} forall ] put
retval (sbs) sbs put
retval (bhs) [sbs length 1 add 2 idiv {height} repeat] put
retval (bbs) [sbs length 1 add 2 idiv {0} repeat] put
includetext {
2428,25 → 2422,25
/barcode exch def % We are given a barcode string
 
barcode (fima) eq {
/sbs [1 1 1 5 1 5 1 1 1] def
/sbs (111515111) def
/bhs [.25 .25 .25 .25 .25] def
/bbs [0 0 0 0 0] def
} if
 
barcode (fimb) eq {
/sbs [1 1 1 5 1 5 1 1 1] def
/sbs (13111311131) def
/bhs [.25 .25 .25 .25 .25 .25] def
/bbs [0 0 0 0 0 0] def
} if
 
barcode (fimc) eq {
/sbs [1 1 1 3 1 3 1 3 1 1 1] def
/sbs (11131313111) def
/bhs [.25 .25 .25 .25 .25 .25] def
/bbs [0 0 0 0 0 0] def
} if
barcode (fimd) eq {
/sbs [1 1 1 1 1 3 1 3 1 1 1 1 1] def
/sbs (1111131311111) def
/bhs [.25 .25 .25 .25 .25 .25 .25] def
/bbs [0 0 0 0 0 0 0] def
} if
2473,19 → 2467,20
/args exch def % We are given some arguments
 
% Default options
/sbs [] def
/sbs () def
/bhs [] def
/bbs [] def
/txt [] def
/barcolor (unset) def
/textcolor (unset) def
/bordercolor (unset) def
/backgroundcolor (unset) def
/barcolor (000000) def
/textcolor (000000) def
/bordercolor (000000) def
/backgroundcolor (FFFFFF) def
/inkspread 0.15 def
/width 0 def
/barratio 1 def
/spaceratio 1 def
/showborder false def
/showbackground false def
/borderleft 10 def
/borderright 10 def
/bordertop 1 def
2534,7 → 2529,7
0 1 sbs length 1 add 2 idiv 2 mul 2 sub {
/i exch def
i 2 mod 0 eq { % i is even
/d sbs i get barratio mul barratio sub 1 add def % d=digit*r-r+1
/d sbs i get 48 sub barratio mul barratio sub 1 add def % d=digit*r-r+1
/h bhs i 2 idiv get 72 mul def % Height from bhs
/c d 2 div x add def % Centre of the bar = x + d/2
/y bbs i 2 idiv get 72 mul def % Baseline from bbs
2542,7 → 2537,7
bars i 2 idiv [h c y w] put % Add the bar entry
h maxh gt {/maxh h def} if
} {
/d sbs i get spaceratio mul spaceratio sub 1 add def % d=digit*r-r+1
/d sbs i get 48 sub spaceratio mul spaceratio sub 1 add def % d=digit*r-r+1
} ifelse
/x x d add def % x+=d
} for
2564,7 → 2559,7
x borderleft add borderright add neg 0 rlineto
0 maxh borderbottom add bordertop add neg rlineto
closepath
backgroundcolor (unset) ne {
showbackground {
gsave
(< >) dup 1 backgroundcolor putinterval cvx exec {255 div} forall setrgbcolor
fill
2571,40 → 2566,16
grestore
} if
showborder {
gsave
bordercolor (unset) ne {
(< >) dup 1 bordercolor putinterval cvx exec {255 div} forall setrgbcolor
} if
(< >) dup 1 bordercolor putinterval cvx exec {255 div} forall setrgbcolor
borderwidth setlinewidth stroke
grestore
} if
% Display the bars for elements in the bars array
gsave
barcolor (unset) ne {
(< >) dup 1 barcolor putinterval cvx exec {255 div} forall setrgbcolor
} if
(< >) dup 1 barcolor putinterval cvx exec {255 div} forall setrgbcolor
bars {
{} forall
newpath setlinewidth moveto 0 exch rlineto stroke
} forall
grestore
% Display the text for elements in the text array
textcolor (unset) ne {
(< >) dup 1 textcolor putinterval cvx exec {255 div} forall setrgbcolor
} if
/s 0 def /f () def
txt {
{} forall
2 copy s ne exch f ne or {
2 copy /s exch def /f exch def
exch findfont exch scalefont setfont
} {
pop pop
} ifelse
moveto show
} forall
 
% Display the guard elements
guardwhitespace {
2625,6 → 2596,20
} if
} if
% Display the text for elements in the text array
(< >) dup 1 textcolor putinterval cvx exec {255 div} forall setrgbcolor
/s 0 def /f () def
txt {
{} forall
2 copy s ne exch f ne or {
2 copy /s exch def /f exch def
exch findfont exch scalefont setfont
} {
pop pop
} ifelse
moveto show
} forall
 
grestore
end