ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: "luigi.scarso" <luigi.scarso@logosrl.it>
Subject: AutoScale and AutoSize
Date: Fri, 15 Apr 2005 09:51:17 +0200	[thread overview]
Message-ID: <425F7275.6070505@logosrl.it> (raw)
In-Reply-To: <d043b689773a5f01c800e2dbe6960f5a@unibas.ch>

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

  parent reply	other threads:[~2005-04-15  7:51 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-15  6:54 justification Jörg Hagmann
2005-04-15  7:35 ` justification luigi.scarso
2005-04-15  9:32   ` justification Jörg Hagmann
2005-04-18 15:52     ` justification Peter Münster
2005-04-15  7:51 ` luigi.scarso [this message]
2005-04-15  9:26   ` AutoScale and AutoSize Hans Hagen
2005-04-15 12:07     ` luigi.scarso
2005-04-15 13:35       ` Hans Hagen
2005-04-15 14:06         ` luigi.scarso
2005-04-15 21:38           ` Hans Hagen
2005-04-18  7:12             ` Strange link on pragma site ? luigi.scarso
2005-04-15  9:43   ` AutoScale and AutoSize luigi.scarso
2005-04-15  9:17 ` justification Hans Hagen
2005-04-15 10:20   ` justification Jörg Hagmann
2005-04-15 21:35     ` justification Hans Hagen
2005-04-15 14:31   ` justification Jörg Hagmann
2005-04-16  7:42   ` Hyphenation-paterns was:Re: justification Willi Egger
2005-04-15 20:12 ` justification Willi Egger
2005-04-16 10:50   ` justification Henning Hraban Ramm
2005-04-18 12:48     ` justification Jörg Hagmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=425F7275.6070505@logosrl.it \
    --to=luigi.scarso@logosrl.it \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).