Article View: adobe.postscript.programming
Article #20Re: Centering Text
From: Jeffrey H. Coffield
Date: Fri, 23 Jan 2009 19:38
Date: Fri, 23 Jan 2009 19:38
31 lines
1912 bytes
1912 bytes
Johann__Myrkraverk__Oskarsson@adobeforums.com wrote:
> Hi,
>
> Here is a routine I have used to center text horizontally on a given x, y location:
>
> /center { % x y string
> /string exch def
> /y exch def
> /x exch def
>
> 0 0 moveto
> string dup stringwidth pop
> 2 div
> x exch sub
> y moveto
> show
> } def
>
> I hope this helps you,
>
> Johann
How about this:
% string x y
/center {moveto dup stringwidth pop -2 div 0 rmoveto show} def
No side effects like redefining x, y and the postscript operator "string".
Jeff Coffield
Technical Details
Message-ID:
<T0pel.12082$as4.6402@nlpi069.nbdc.sbc.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!newshub.sdsu.edu!flph200.ffdc.sbc.com!prodigy.net!flph199.ffdc.sbc.com!prodigy.com!flpi107.ffdc.sbc.com!nlpi069.nbdc.sbc.com.POSTED!cbb6f965!not-for-mailReferences:
<59b7a6d8.-1@webcrossing.la2eafNXanI> <59b7a6d8.0@webcrossing.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Thread: 10c61a,fc8ee9deb0c99d17 X-Google-Attributes: gid10c61a,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!newshub.sdsu.edu!flph200.ffdc.sbc.com!prodigy.net!flph199.ffdc.sbc.com!prodigy.com!flpi107.ffdc.sbc.com!nlpi069.nbdc.sbc.com.POSTED!cbb6f965!not-for-mail From: "Jeffrey H. Coffield" <jeffrey@digitalsynergyinc.com> User-Agent: Thunderbird 2.0.0.19 (X11/20081227) MIME-Version: 1.0 Newsgroups: adobe.postscript.programming Subject: Re: Centering Text References: <59b7a6d8.-1@webcrossing.la2eafNXanI> <59b7a6d8.0@webcrossing.la2eafNXanI> In-Reply-To: <59b7a6d8.0@webcrossing.la2eafNXanI> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Lines: 31 Message-ID: <T0pel.12082$as4.6402@nlpi069.nbdc.sbc.com> NNTP-Posting-Host: 216.103.32.162 X-Complaints-To: abuse@prodigy.net X-Trace: nlpi069.nbdc.sbc.com 1232739507 ST000 216.103.32.162 (Fri, 23 Jan 2009 14:38:27 EST) NNTP-Posting-Date: Fri, 23 Jan 2009 14:38:27 EST Organization: at&t http://my.att.net/ X-UserInfo1: [[PAPDCA[S@URQPYHJINOPD@UKXD@D@MGPW^OBPLAH[\RYIBK^RAQFW[ML\THRCKV^GGZKJMGV^^_JSCFFUA_QXFGVSCYRPILH]TRVKC^LSN@DX_HCAFX__@J\DAJBVMY\ZWZCZLPA^MVH_P@\\EOMW\YSXHG__IJQY_@M[A[[AXQ_XDSTAR]\PG]NVAQUVM Date: Fri, 23 Jan 2009 11:38:27 -0800