Commit fa35d42d authored by Peter Billam's avatar Peter Billam

add str_in_rect, though still undocumented

parent 423cc2b3
......@@ -300,6 +300,31 @@ end
end
} def
% 20181122
% ( perhaps useful: a way to _scale_ a sequence of calls to a given width,
% but perhaps best just to do it, measure currentpoint, then re-do it )
/str_in_rect { % str xmargin ymargin fgcolor bgcolor str_in_rect -> y_top
% See http://www.ubu.com/film/sackner_concrete.html at 06:30
20 dict begin
[/bgb /bgg /bgr /fgb /fgg /fgr /ymargin /xmargin /str] {exch def} forall
currentpoint /cpy exch def /cpx exch def % remember the currentpoint
gsave % measure bbox of the string, including unwanted blanks llx and lly
0 0 moveto str true charpath flattenpath pathbbox
[ /ury /urx /lly /llx ] { exch def } forall
grestore
bgr bgg bgb setrgbcolor
cpx cpy
xmargin urx add llx sub xmargin add
ury lly sub ymargin add ymargin add rectfill
fgr fgg fgb setrgbcolor
xmargin llx sub ymargin lly sub rmoveto str show
% leave the currentpoint at the lower-right corner !
cpx llx sub xmargin add urx add xmargin add cpy moveto
ury lly sub ymargin add ymargin add cpy add % leave y_top on the stack !
end
} def
% all the following are taken from muscript -p or muscript.ps
/rightshow where { pop } { % might also be set by muscript.ps ...
/rightshow { % usage: x y font fontsize (string) rightshow
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment