![](https://secure.gravatar.com/avatar/ed6f43113e3f1cee031ebd13654fc703.jpg?s=120&d=mm&r=g)
On 2/9/2023 10:42 PM, Bruce Horrocks via ntg-context wrote:
I'm printing address labels. Sometimes an address has a long line that is too long to fit on the label with the result that it wraps. Instead of wrapping, I thought it would be nice to try and auto-scale the label and shrink it so that the long line just fits.
I'm using \crlf to break the address into lines and this doesn't play well with the \scale command, see MWE below, where the second frame is just one long line as the \crlf's seem to be ignored.
Is there a simple solution that allows \crlf and also scale?
\starttext \startbuffer[address] Name \crlf Address 1 \crlf A long line that wraps \crlf Town \crlf Postcode \stopbuffer \framed[width=3cm,align=flushleft]{\getbuffer[address]} \framed[width=3cm,align=flushleft]{\scale[factor=fit]{\getbuffer[address]}} \stoptext \starttext
\startbuffer[address] Name Address 1 A long line that wraps Town Postcode \stopbuffer \framed [align=flushleft,strut=no] {\startlines[before=,after=] \getbuffer[address] \stoplines} \scale [width=3cm] {\framed [align=flushleft,strut=no] {\startlines[before=,after=] \getbuffer[address] \stoplines}} \stoptext You can of course adapt the font size instead but as it's just stickers the above is probably good enough, but you can do this: \begingroup \doloop { \setbox\scratchbox\hbox\bgroup\framed [align={flushleft},strut=no] {\startlines[before=,after=] \getbuffer[address] \stoplines} \egroup \ifdim\wd\scratchbox>3cm \advance\glyphscale by -50 \else \box\scratchbox \exitloop \fi } \endgroup to get more consistent stepwise scaling or even this: \begingroup \doloop { \setbox\scratchbox\hbox\bgroup\framed [align={flushleft},strut=no] {\startlines[before=,after=] \getbuffer[address] \stoplines} \egroup \ifdim\wd\scratchbox>3cm \advance\glyphxscale by -50 \else \framed [align={flushleft},strut=no,width=3cm] {\startlines[before=,after=] \getbuffer[address] \stoplines} \exitloop \fi } \endgroup which is what i might choose eventually (i'll add it to the test suite) Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------