I have this, But I want to have text alignment like an arc. Is it possible?
/outputtext {
/data exch def
/rot exch def
/xfont exch def
/y1 exch def
/x1 exch def
/Times-Roman findfont
xfont scalefont
setfont
x1 y1 moveto
rot rotate
data show
rot neg rotate
} def
% x y fontsize rotation (text) outputtext
20 300 12 0 (text1) outputtext
20 400 12 90 (text2) outputtext
20 500 12 90 (text3) outputtext
20 600 12 0 (text4) outputtext
showpage
Adobe's famous Blue Book (PostScript Language Tutorial and Cookbook, Adobe Systems, Addison-Wesley 1985; ISBN 0201101793) contains a very well explained example how to do this.
See pages 168ff and the following screenshot:
Not sure why you want to avoid translate, and it's not clear what you mean by "dynamically". But this code gives rotation-like effects without translating. But you can't really hug an arc without defining a center (either with translate and rotate, or algebraically with cos and sin) and accounting (somehow) for the character widths. The Adobe example code does all of this. My code here does not.
%!
/rottxt { 4 dict begin
/ang exch def
/str exch def
/ang ang str length div def
{ pop pop ang rotate }
str
kshow
end } def
30 150 moveto
/Palatino-Roman 20 selectfont
(This is) -20 rottxt
( some ro) 20 rottxt
(tated T) -40 rottxt
(ext!!!!!) -100 rottxt
showpage
I think at long last I understand what you're trying to do. The part about translate really threw me for a loop. There's nothing to fear about translate. And it will be necessary. Translate is what lets you control where the center of rotation is.
So you want to draw text on a circle, but you want to change font parameters dynamically. Font-changes in the middle of an arc. That'll take some thought. I'll edit when I've got more.
来源:https://stackoverflow.com/questions/12599627/how-can-i-write-arc-text-in-postscript-file