Skip to content

Commit cdfc94c

Browse files
committed
rendertext: Consistency
1 parent c6204d9 commit cdfc94c

File tree

1 file changed

+34
-35
lines changed

1 file changed

+34
-35
lines changed

src/rendertext.ps.src

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -38,51 +38,51 @@ true setglobal
3838
dup /raiseerror dup /uk.co.terryburton.bwipp findresource put
3939
begin
4040

41-
/rendertextpositions <<
41+
/rendertext.positions <<
4242
% direction
43-
% x-align y-align
43+
% x-align y-align
4444
(forward) <<
45-
(offleft) { tw neg nudge sub } (below) { th neg nudge sub }
46-
(left) { 0 } (bottom) { 0 }
47-
(xcenter) { pixx tw sub 2 div } (ycenter) { pixy th sub 2 div }
48-
(right) { pixx tw sub } (top) { pixy th sub }
49-
(offright) { pixx nudge add } (above) { pixy nudge add }
45+
(offleft) { tw neg nudge sub } bind (below) { th neg nudge sub } bind
46+
(left) { 0 } bind (bottom) { 0 } bind
47+
(xcenter) { pixx tw sub 2 div } bind (ycenter) { pixy th sub 2 div } bind
48+
(right) { pixx tw sub } bind (top) { pixy th sub } bind
49+
(offright) { pixx nudge add } bind (above) { pixy nudge add } bind
5050
>>
5151
(backward) <<
52-
(offleft) { 0 nudge sub } (below) { 0 nudge sub }
53-
(left) { tw } (bottom) { th }
54-
(xcenter) { pixx tw add 2 div } (ycenter) { pixy th add 2 div }
55-
(right) { pixx } (top) { pixy }
56-
(offright) { pixx tw add nudge add } (above) { pixy th add nudge add }
52+
(offleft) { 0 nudge sub } bind (below) { 0 nudge sub } bind
53+
(left) { tw } bind (bottom) { th } bind
54+
(xcenter) { pixx tw add 2 div } bind (ycenter) { pixy th add 2 div } bind
55+
(right) { pixx } bind (top) { pixy } bind
56+
(offright) { pixx tw add nudge add } bind (above) { pixy th add nudge add } bind
5757
>>
5858
(upward) <<
59-
(offleft) { 0 nudge sub } (below) { tw neg nudge sub }
60-
(left) { th } (bottom) { 0 }
61-
(xcenter) { pixx th add 2 div } (ycenter) { pixy tw sub 2 div }
62-
(right) { pixx } (top) { pixy tw sub }
63-
(offright) { pixx th add nudge add } (above) { pixy nudge add }
59+
(offleft) { 0 nudge sub } bind (below) { tw neg nudge sub } bind
60+
(left) { th } bind (bottom) { 0 } bind
61+
(xcenter) { pixx th add 2 div } bind (ycenter) { pixy tw sub 2 div } bind
62+
(right) { pixx } bind (top) { pixy tw sub } bind
63+
(offright) { pixx th add nudge add } bind (above) { pixy nudge add } bind
6464
>>
6565
(downward) <<
66-
(offleft) { th neg nudge sub } (below) { 0 nudge sub }
67-
(left) { 0 } (bottom) { tw }
68-
(xcenter) { pixx th sub 2 div } (ycenter) { pixy tw add 2 div }
69-
(right) { pixx th sub } (top) { pixy }
70-
(offright) { pixx nudge add } (above) { pixy tw add nudge add }
66+
(offleft) { th neg nudge sub } bind (below) { 0 nudge sub } bind
67+
(left) { 0 } bind (bottom) { tw } bind
68+
(xcenter) { pixx th sub 2 div } bind (ycenter) { pixy tw add 2 div } bind
69+
(right) { pixx th sub } bind (top) { pixy } bind
70+
(offright) { pixx nudge add } bind (above) { pixy tw add nudge add } bind
7171
>>
7272
>> def
7373

74-
% x-align y-align direction text-width text-height
75-
/rendertextpositiontext {
76-
/th exch def
77-
/tw exch def
78-
/nudge 1 def
79-
//rendertextpositions exch get dup
80-
4 -1 roll dup (center) eq {pop (xcenter)} if get exec exch
81-
3 -1 roll dup (center) eq {pop (ycenter)} if get exec
82-
} bind def
83-
8474
/rendertext {
8575

76+
% x-align y-align direction text-width text-height
77+
/positiontext {
78+
/th exch def
79+
/tw exch def
80+
/nudge 1 def
81+
//rendertext.positions exch get dup
82+
4 -1 roll dup (center) eq {pop (xcenter)} if get exec exch
83+
3 -1 roll dup (center) eq {pop (ycenter)} if get exec
84+
} def
85+
8686
% Display the text for elements in the text array
8787
includetext {
8888

@@ -184,7 +184,7 @@ begin
184184
} ifelse
185185
} if
186186

187-
textxalign textyalign textdirection textwidth textheight //rendertextpositiontext exec moveto
187+
textxalign textyalign textdirection textwidth textheight positiontext exec moveto
188188
textxoffset textyoffset rmoveto
189189
gsave
190190
<< (forward) 0 (upward) 90 (backward) 180 (downward) 270 >> textdirection get rotate
@@ -268,7 +268,7 @@ begin
268268
} ifelse
269269
} if
270270

271-
extratextxalign extratextyalign extratextdirection textwidth textheight //rendertextpositiontext exec moveto
271+
extratextxalign extratextyalign extratextdirection textwidth textheight positiontext exec moveto
272272
extratextxoffset extratextyoffset rmoveto
273273
gsave
274274
<< (forward) 0 (upward) 90 (backward) 180 (downward) 270 >> extratextdirection get rotate
@@ -286,7 +286,6 @@ begin
286286
[/barcode] {null def} forall
287287
bind def
288288
/rendertext dup load /uk.co.terryburton.bwipp defineresource pop
289-
290289
end
291290
/setpacking where {pop setpacking} if
292291
setglobal

0 commit comments

Comments
 (0)