Skip to content

Commit 0d91118

Browse files
committed
Add hooks to DM and QR.
1 parent fc0bad5 commit 0d91118

2 files changed

Lines changed: 45 additions & 2 deletions

File tree

‎src/datamatrix.ps.src‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
% IN THE SOFTWARE.
3333

3434
% --BEGIN ENCODER datamatrix--
35-
% --REQUIRES preamble raiseerror processoptions parseinput setanycolor fifocache rendertext renmatrix--
35+
% --REQUIRES preamble raiseerror processoptions parseinput setanycolor fifocache setuphooks rendertext renmatrix--
3636
% --DESC: Data Matrix
3737
% --EXAM: This is Data Matrix!
3838
% --EXOP:
@@ -45,9 +45,12 @@ dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
4545
dup /processoptions dup /uk.co.terryburton.bwipp findresource put
4646
dup /parseinput dup /uk.co.terryburton.bwipp findresource put
4747
dup /fifocache dup /uk.co.terryburton.bwipp findresource put
48+
dup /setuphooks dup /uk.co.terryburton.bwipp findresource put
4849
dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
4950
begin
5051

52+
/datamatrix [/before /after] //setuphooks exec
53+
5154
%
5255
% Basic metrics for each symbol
5356
%
@@ -465,6 +468,8 @@ begin
465468

466469
} {
467470

471+
(preprocess) //datamatrix.before exec
472+
468473
%
469474
% Parse the input
470475
%
@@ -858,6 +863,10 @@ begin
858863
/mode //datamatrix.A def
859864
} def
860865

866+
(preprocess) //datamatrix.after exec
867+
868+
(codewords) //datamatrix.before exec
869+
861870
%
862871
% Derive the codewords
863872
%
@@ -885,6 +894,8 @@ begin
885894
} for
886895
} if
887896

897+
(codewords) //datamatrix.after exec
898+
888899
options /debugcws known
889900
/uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledebug known} {pop false} ifelse
890901
and { /bwipp.debugcws cws //raiseerror exec } if
@@ -920,6 +931,8 @@ begin
920931
/bwipp.datamatrixNoValidSymbol (Maximum length exceeded or invalid size) //raiseerror exec
921932
} if
922933

934+
(ecc) //datamatrix.before exec
935+
923936
%
924937
% De-interleave the codewords into blocks
925938
%
@@ -987,6 +1000,10 @@ begin
9871000
cws ncws i add ecbs i rsbl mod get i rsbl idiv get put
9881001
} for
9891002

1003+
(ecc) //datamatrix.after exec
1004+
1005+
(matrix) //datamatrix.before exec
1006+
9901007
%
9911008
% Place codeword bits into matrix
9921009
%
@@ -1089,6 +1106,8 @@ begin
10891106
} if
10901107
} for
10911108

1109+
(matrix) //datamatrix.after exec
1110+
10921111
<<
10931112
/ren /renmatrix
10941113
/pixs pixs

‎src/qrcode.ps.src‎

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
% IN THE SOFTWARE.
3333

3434
% --BEGIN ENCODER qrcode--
35-
% --REQUIRES preamble raiseerror processoptions parseinput setanycolor fifocache rendertext renmatrix--
35+
% --REQUIRES preamble raiseerror processoptions parseinput setanycolor fifocache setuphooks rendertext renmatrix--
3636
% --DESC: QR Code
3737
% --EXAM: http://goo.gl/0bis
3838
% --EXOP: eclevel=M
@@ -45,6 +45,7 @@ dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
4545
dup /processoptions dup /uk.co.terryburton.bwipp findresource put
4646
dup /parseinput dup /uk.co.terryburton.bwipp findresource put
4747
dup /fifocache dup /uk.co.terryburton.bwipp findresource put
48+
dup /setuphooks dup /uk.co.terryburton.bwipp findresource put
4849
dup /renmatrix dup /uk.co.terryburton.bwipp findresource put
4950
begin
5051

@@ -680,6 +681,8 @@ begin
680681
//qrcode.coeffscache /fetch get exec
681682
} bind def
682683

684+
/qrcode [/before /after] //setuphooks exec
685+
683686
/qrcode {
684687

685688
256 dict begin
@@ -749,6 +752,8 @@ begin
749752
} if
750753
} if
751754

755+
(preprocess) //qrcode.before exec
756+
752757
%
753758
% Parse the input
754759
%
@@ -932,6 +937,9 @@ begin
932937
} ifelse
933938
} for
934939

940+
(preprocess) //qrcode.after exec
941+
(codewords) //qrcode.before exec
942+
935943
/KbeforeB {numK exch ver get ge nextBs numK 2 mul i add get 0 eq and} def
936944
/KbeforeA {numK exch ver get ge nextAs numK 2 mul i add get 0 eq and} def
937945
/KbeforeN {numK exch ver get ge nextNs numK 2 mul i add get 0 eq and} def
@@ -1243,10 +1251,14 @@ begin
12431251
%
12441252
lc4b {cws cws length 1 sub 2 copy get 4 bitshift put} if
12451253

1254+
(codewords) //qrcode.after exec
1255+
12461256
options /debugcws known
12471257
/uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledebug known} {pop false} ifelse
12481258
and { /bwipp.debugcws cws //raiseerror exec } if
12491259

1260+
(ecc) //qrcode.before exec
1261+
12501262
%
12511263
% Fetch the coefficients (cached)
12521264
%
@@ -1337,10 +1349,14 @@ begin
13371349
cws ncws 1 sub cws ncws 1 sub get 15 and 4 bitshift put
13381350
} if
13391351

1352+
(ecc) //qrcode.after exec
1353+
13401354
options /debugecc known
13411355
/uk.co.terryburton.bwipp.global_ctx dup where {exch get /enabledebug known} {pop false} ifelse
13421356
and { /bwipp.debugecc cws //raiseerror exec } if
13431357

1358+
(matrix) //qrcode.before exec
1359+
13441360
%
13451361
% Create the bitmap
13461362
%
@@ -1551,6 +1567,9 @@ begin
15511567
} ifelse
15521568
} loop
15531569

1570+
(matrix) //qrcode.after exec
1571+
(masking) //qrcode.before exec
1572+
15541573
%
15551574
% Evaluate runlength encoded rows or columns in full symbols
15561575
%
@@ -1690,6 +1709,9 @@ begin
16901709
} for
16911710
/pixs bestsym def
16921711

1712+
(masking) //qrcode.after exec
1713+
(finalise) //qrcode.before exec
1714+
16931715
%
16941716
% Set the solitary dark module in full symbols
16951717
%
@@ -1742,6 +1764,8 @@ begin
17421764
} for
17431765
} if
17441766

1767+
(finalise) //qrcode.after exec
1768+
17451769
%
17461770
% Return the arguments
17471771
%

0 commit comments

Comments
 (0)