From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/19878 Path: news.gmane.org!not-for-mail From: "luigi.scarso" Newsgroups: gmane.comp.tex.context Subject: AutoScale and AutoSize Date: Fri, 15 Apr 2005 09:51:17 +0200 Message-ID: <425F7275.6070505@logosrl.it> References: Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1113552621 19431 80.91.229.2 (15 Apr 2005 08:10:21 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 15 Apr 2005 08:10:21 +0000 (UTC) Original-X-From: ntg-context-bounces@ntg.nl Fri Apr 15 10:10:19 2005 Return-path: Original-Received: from ronja.vet.uu.nl ([131.211.172.88] helo=ronja.ntg.nl) by ciao.gmane.org with esmtp (Exim 4.43) id 1DMLtf-0002Kg-PI for gctc-ntg-context-518@m.gmane.org; Fri, 15 Apr 2005 10:09:51 +0200 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 0E84A1292C; Fri, 15 Apr 2005 10:13:22 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (ronja.vet.uu.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 20212-01-2; Fri, 15 Apr 2005 10:13:21 +0200 (CEST) Original-Received: from ronja.vet.uu.nl (localhost.localdomain [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 689A612935; Fri, 15 Apr 2005 09:51:24 +0200 (CEST) Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 4FD1812935 for ; Fri, 15 Apr 2005 09:51:23 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (ronja.vet.uu.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 19960-03 for ; Fri, 15 Apr 2005 09:51:22 +0200 (CEST) Original-Received: from ServerNotes.logosrl.it (unknown [81.208.99.91]) by ronja.ntg.nl (Postfix) with ESMTP id 81611127A8 for ; Fri, 15 Apr 2005 09:51:22 +0200 (CEST) Original-Received: from [192.168.2.85] ([192.168.2.85]) by ServerNotes.logosrl.it (Lotus Domino Release 6.5.1) with ESMTP id 2005041509474985-655 ; Fri, 15 Apr 2005 09:47:49 +0200 User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) X-Accept-Language: en-us, en Original-To: mailing list for ConTeXt users In-Reply-To: X-MIMETrack: Itemize by SMTP Server on ServerNotes/Logo(Release 6.5.1|January 21, 2004) at 15/04/2005 09.47.49, Serialize by Router on ServerNotes/Logo(Release 6.5.1|January 21, 2004) at 15/04/2005 09.47.50, Serialize complete at 15/04/2005 09.47.50 X-Virus-Scanned: by amavisd-new at ntg.nl X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.5 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: ntg-context-bounces@ntg.nl Errors-To: ntg-context-bounces@ntg.nl X-Virus-Scanned: by amavisd-new at ntg.nl Xref: news.gmane.org gmane.comp.tex.context:19878 X-Report-Spam: http://spam.gmane.org/gmane.comp.tex.context:19878 I have to typeset a small paragraph inside fixed box. I don't have much control about it's content, so sometimes text overflow. I try the following two macros, but they aren't good. % AutoScaled: not what I really want, but % sometimes works % \def\AutoScaled#1#2#3#4#5{% % #1 horiz. limit % #2 unused (maybe vert. limit) % #3 horiz. scale % #4 vert. scale % #5 text \setbox800=\hbox{\color[black]{\scale[sx=#3,sy=#4]{\bf #5}}}% \newdimen\ScaleX \ScaleX=#3pt \newdimen\ScaleY \ScaleY=#4pt %% \newdimen\LimitX \LimitX=#1 % \ifdim\wd800 > \LimitX % \edef\Ratio{\withoutpt{\the\dimexpr( (2\LimitX/(\wd800 /32768))) }}% \edef\XSCALE{\withoutpt{\the\dimexpr( \Ratio\ScaleX ) }}% \edef\YSCALE{\withoutpt{\the\dimexpr( \Ratio\ScaleY ) }}% \setbox800=\hbox{\color[black]{\scale[sx=\XSCALE,sy=\YSCALE]{\bf #5}}}% \fi% \box800\relax% }%%enddef \Autoscaled %AutoSize is what I really want, but it's %WRONG!! \def\AutoSize#1#2#3{% % #1=string #2=horiz.limit #3=initial font size \newdimen\Limit \Limit=#2 \newdimen\FontSize \FontSize=#3 \doloop{% \setbox800=\hbox{#1}% \ifdim\wd800 <\Limit\exitloop \else % WARNING: eat memory , 1bp is bad step, % force ss .... it's wrong \advance\FontSize by -1bp\switchtobodyfont[ss,\the\FontSize]% %% \fi}% %\newdimen\Dimen \Dimen=0.35277778\wd800 \pointless\Dimen mm\relax% \box800\relax% } luigi