6161 /textxoffset 0.0 def
6262 /textyoffset 0.0 def
6363 /textgaps 0.0 def
64+ /textlinegaps 1.2 def
6465 /alttext () def
66+ /alttextsplit () def
6567 /alttextsubspace () def
6668 /extratext () def
6769 /extratextsubspace () def
@@ -385,7 +387,20 @@ begin
385387 } if
386388 } ifelse
387389 /textascent exch def
388- /textwidth tstr stringwidth pop tstr length 1 sub textgaps mul add def
390+
391+ alttext () ne alttextsplit () ne and {
392+ alttextsplit length 1 ne {
393+ /bwipp.alttextsplitBad (The alttextsplit option must be a single character) //raiseerror exec
394+ } if
395+ /textlines [
396+ tstr { alttextsplit search { exch pop exch } { exit } ifelse } loop
397+ ] def
398+ } {
399+ /textlines [ tstr ] def
400+ } ifelse
401+
402+ /textwidth 0 textlines { stringwidth pop 2 copy lt {exch} if pop } forall tstr length 1 sub textgaps mul add def
403+ /textheight textlines length dup textascent mul exch 1 sub textlinegaps mul add def
389404
390405 /textxpos textxoffset pixx textwidth sub 2 div add def
391406 textxalign (left) eq { /textxpos textxoffset def } if
@@ -396,10 +411,16 @@ begin
396411 /textxpos 0.0 def
397412 /textgaps pixx textwidth sub tstr length 1 sub div def
398413 } if
399- /textypos textyoffset textascent add 1 add neg def
414+ /textypos textyoffset textheight add 1 add neg def
400415 textyalign (above) eq { /textypos textyoffset pixy add 1 add def } if
401- textyalign (center) eq { /textypos textyoffset pixy textascent sub 2 div add def } if
402- textxpos textypos moveto textgaps 0 tstr ashow
416+ textyalign (center) eq { /textypos textyoffset pixy textheight sub 2 div add def } if
417+
418+ 0 1 textlines length 1 sub {
419+ /i exch def
420+ textxpos textypos textascent textlinegaps add i mul add moveto
421+ textgaps 0 textlines dup length i sub 1 sub get ashow
422+ } for
423+
403424 } ifelse
404425 } if
405426
0 commit comments