Commit fa35d42d authored by Peter Billam's avatar Peter Billam

add str_in_rect, though still undocumented

parent 423cc2b3
......@@ -300,6 +300,31 @@ 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 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
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 !
} def
% all the following are taken from muscript -p or
/rightshow where { pop } { % might also be set by ...
/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