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 — Bruce Horrocks Hampshire, UK
Am 09.02.23 um 22:42 schrieb Bruce Horrocks via ntg-context:
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
Did you try \framedtext instead of \framed? (I didn’t test.) Hraban
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 -----------------------------------------------------------------
On 10 Feb 2023, at 09:20, Hans Hagen via ntg-context
wrote:
[snip] Thank-you Hans, these work great - so well in fact that now I've seen the output I've come to the conclusion that the scaled text would be too small and what I should really do is flag the one or two addresses in our mailing list that have long lines and print them on larger labels in a separate run. :-) — Bruce Horrocks Hampshire, UK
participants (3)
-
Bruce Horrocks
-
Hans Hagen
-
Henning Hraban Ramm