Microsoft KB Archive/61025

Word: Using PostScript to Print Text Around a Circle

PSS ID Number: Q61025 Article last modified on 03-07-1997

=
========================================================= 3.00 3.01 3.02 4.00 MACINTOSH kbprint kbgraphic

= SUMMARY =

Using PostScript code, you can print text around a circle in Microsoft Word. The resulting code is placed on the page independent of any normal text or graphics used by Word. The following is an example of code that will do this.

Sample Code
/Times-Roman findfont 24 scalefont setfont gsave /st (Witness the glorious spectacle of text in a circle.) def /st2 1 string def /r 144 def /c 6.28318530 r mul def /findc { c div 360 mul } bind def 306 386 translate st stringwidth pop 2 div findc rotate 0 r moveto {pop st2 0 3 -1 roll put st2 stringwidth pop findc neg rotate 0 r moveto } st kshow grestore

= MORE INFORMATION =

The following is a line-by-line explanation of this code:

/Times-Roman findfont 24 scalefont setfont

Establishes the current font as “Times-Roman” at 24 point size. The size can be changed by changing the number 24. The font can be changed by changing “Times-Roman” to an installed LaserWriter font.

gsave

Saves the current graphics state so it can be restored later. That way, any PostScript code entered after this code will not be affected by this code.

/st (Witness the glorious spectacle of text in a circle.) def

This is the text to be printed. A string of any length (within reason) can be inserted between the parentheses.

/st2 1 string def

Defines an empty string with one character in it.

/r 144 def

Defines the radius of the circle around which the text will be drawn. Any number (within reason) can be substituted for 144. This number is in points. One inch is 72 points.

/c 6.28318530 r mul def

Calculates the circumference of the circle using the formula 2piradius.

/findc {c div 360 mul} bind def

Defines a procedure “findc.” This procedure takes a number off the stack, figures the ratio of that number to the circumference of the circle, and translates the number to degrees.

306 386 translate

Moves the origin from the lower-left corner of the page right 306 points and up 386 points. This point will be the center of the circle. These numbers can be changed.

st stringwidth pop 2 div findc rotate

Finds the length of the string defined above (“Witness the…”) and uses the procedure “findc” to find the number of degrees it is necessary to rotate the origin to set the y-axis at the beginning of the string.

0 r moveto

Moves to a point on the y-axis the distance of the radius from the origin of the coordinate system.

{pop st2 0 3 -1 roll put st2 stringwidth pop findc neg rotate 0 r moveto}

This procedure is repeated between every letter that is shown on the page. The letter is placed in a string (first line), the width of the letter is determined, and the number of degrees that the origin must be rotated to place the y-axis directly after the letter is discovered using the findc procedure (second line). The current point is then placed on the y-axis, a distance of the radius from the origin (third line).

st kshow

Shows the string “st” (“Witness the…”), performing the above procedure between every letter.

grestore

Restores the graphic’s state to its original condition when gsave was used.

KBCategory: kbprint kbgraphic KBSubCategory: kbformula Additional reference words: macword eps macword5 ====================================================================== ============================================================================= Copyright Microsoft Corporation 1997.