* Problem using \scale
@ 2023-02-09 21:42 Bruce Horrocks via ntg-context
2023-02-10 7:04 ` Henning Hraban Ramm via ntg-context
2023-02-10 9:20 ` Hans Hagen via ntg-context
0 siblings, 2 replies; 4+ messages in thread
From: Bruce Horrocks via ntg-context @ 2023-02-09 21:42 UTC (permalink / raw)
To: ntg-context mailing list; +Cc: Bruce Horrocks
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
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage : https://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Problem using \scale
2023-02-09 21:42 Problem using \scale Bruce Horrocks via ntg-context
@ 2023-02-10 7:04 ` Henning Hraban Ramm via ntg-context
2023-02-10 9:20 ` Hans Hagen via ntg-context
1 sibling, 0 replies; 4+ messages in thread
From: Henning Hraban Ramm via ntg-context @ 2023-02-10 7:04 UTC (permalink / raw)
To: Bruce Horrocks via ntg-context; +Cc: Henning Hraban Ramm
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
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage : https://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Problem using \scale
2023-02-09 21:42 Problem using \scale Bruce Horrocks via ntg-context
2023-02-10 7:04 ` Henning Hraban Ramm via ntg-context
@ 2023-02-10 9:20 ` Hans Hagen via ntg-context
2023-02-10 19:05 ` Bruce Horrocks via ntg-context
1 sibling, 1 reply; 4+ messages in thread
From: Hans Hagen via ntg-context @ 2023-02-10 9:20 UTC (permalink / raw)
To: Bruce Horrocks via ntg-context; +Cc: Hans Hagen
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
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage : https://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Problem using \scale
2023-02-10 9:20 ` Hans Hagen via ntg-context
@ 2023-02-10 19:05 ` Bruce Horrocks via ntg-context
0 siblings, 0 replies; 4+ messages in thread
From: Bruce Horrocks via ntg-context @ 2023-02-10 19:05 UTC (permalink / raw)
To: ntg-context mailing list; +Cc: Bruce Horrocks
> On 10 Feb 2023, at 09:20, Hans Hagen via ntg-context <ntg-context@ntg.nl> 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
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage : https://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-02-10 19:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-09 21:42 Problem using \scale Bruce Horrocks via ntg-context
2023-02-10 7:04 ` Henning Hraban Ramm via ntg-context
2023-02-10 9:20 ` Hans Hagen via ntg-context
2023-02-10 19:05 ` Bruce Horrocks via ntg-context
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).