Hello again, it's been a while... ;-) I need to pack fixed lines into a fixed width box. Some years ago I had something similar in plain PostScript, where I pre-calculated the width of a text box, let the default font if it would fit my max size, otherwise try a narrow font and if that wasn’t enough decreased font size until it would fit. This time I've only one font and must not decrease font size, but must use negative kerning and perhaps some artificial narrowing. How can I do that with ConTeXt? I use MkIV, so any Lua solution is welcome. Greetlings from Lake Constance! Hraban --- http://www.fiee.net/texnique/ http://wiki.contextgarden.net https://www.cacert.org (I'm an assurer)
On 17-5-2011 1:25, Henning Hraban Ramm wrote:
Hello again, it's been a while... ;-)
I need to pack fixed lines into a fixed width box.
Some years ago I had something similar in plain PostScript, where I pre-calculated the width of a text box, let the default font if it would fit my max size, otherwise try a narrow font and if that wasn’t enough decreased font size until it would fit.
This time I've only one font and must not decrease font size, but must use negative kerning and perhaps some artificial narrowing. How can I do that with ConTeXt? I use MkIV, so any Lua solution is welcome.
\starttext \definefontfeature[realugly][default][extend=0.25] \definedfont[Serif*realugly] Only You Can Read This \stoptext ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
Am 2011-05-17 um 13:53 schrieb Hans Hagen:
On 17-5-2011 1:25, Henning Hraban Ramm wrote:
Hello again, it's been a while... ;-)
I need to pack fixed lines into a fixed width box.
Some years ago I had something similar in plain PostScript, where I pre-calculated the width of a text box, let the default font if it would fit my max size, otherwise try a narrow font and if that wasn’t enough decreased font size until it would fit.
This time I've only one font and must not decrease font size, but must use negative kerning and perhaps some artificial narrowing. How can I do that with ConTeXt? I use MkIV, so any Lua solution is welcome.
\starttext
\definefontfeature[realugly][default][extend=0.25]
\definedfont[Serif*realugly] Only You Can Read This
\stoptext
Thank you - but this is fixed narrowing. I also found stretching to a fixed width using \stretched: \hbox to 3.9cm{\stretched{Täxt wÿth ſpöciäl çhaŕàćťërs}} (You don’t need to escape Unicode chars anymore, in contrast to the docs/source.) But what I really need is some width checking like "if this line is wider than 4cm, then use stretching/narrowing". I don’t want to murder typography if the text is short enough. Greetlings from Lake Constance! Hraban --- http://www.fiee.net/texnique/ http://wiki.contextgarden.net https://www.cacert.org (I'm an assurer)
Hi, I want to measure and typeset the lower case alphabet length. The LaTeX method doesn't work: \newlength{\alphabetlength} \settowidth{\alphabetlength}{abcdefghijklmnopqrstuvwxyz} \the\alphabetlength ConTeXt gives me an error saying that \newlength{...} is undefined. Is it undefined because ConTeXt is built around TeX and not LaTeX and \newlength is a LaTeX command (I do not know if it actually is)? How can I do the same thing in ConTeXt? Regards Christoph
On Mon, Jun 13, 2011 at 2:15 PM, Christoph Redecker
Hi,
I want to measure and typeset the lower case alphabet length. The LaTeX method doesn't work:
\newlength{\alphabetlength} \settowidth{\alphabetlength}{abcdefghijklmnopqrstuvwxyz} \the\alphabetlength
ConTeXt gives me an error saying that \newlength{...} is undefined. Is it undefined because ConTeXt is built around TeX and not LaTeX and \newlength is a LaTeX command (I do not know if it actually is)? yes
How can I do the same thing in ConTeXt? plain TeX is ok, for example, \newdimen\AlphaBet \bgroup \setbox10=\hbox{abcdefghijklmnopqrstuvwxyz} \global\AlphaBet=\wd10\egroup \the\AlphaBet
Use CamelCase to avoid conflits with ConTeXt names. There are much more at http://wiki.contextgarden.net/Category:ConTeXt_programming -- luigi
Am 13.06.2011 um 14:30 schrieb luigi scarso:
How can I do the same thing in ConTeXt? plain TeX is ok, for example, \newdimen\AlphaBet \bgroup \setbox10=\hbox{abcdefghijklmnopqrstuvwxyz} \global\AlphaBet=\wd10\egroup \the\AlphaBet
\starttext \dowithnextbox {\edef\AlphabetLength{\the\nextboxwd}}% \hbox{abcdefghijklmnopqrstuvwxyz} \AlphabetLength \stoptext Hans wrote also a command for this but it never went into core: http://archive.contextgarden.net/message/20070314.120612.adab0a8b.en.html Wolfgang
Am 13.06.2011 um 14:34 schrieb Wolfgang Schuster:
\starttext
\dowithnextbox {\edef\AlphabetLength{\the\nextboxwd}}% \hbox{abcdefghijklmnopqrstuvwxyz}
\AlphabetLength
\stoptext
Or even better: \starttext \dowithnextbox {\definemeasure[alphabetlength][\the\nextboxwd]}% \hbox{abcdefghijklmnopqrstuvwxyz} \measure{alphabetlength} \stoptext Wolfgang
Thanks to both of you, all three suggestions work. However, I don't understand all of the code. What does \dowithnextbox do exactly? In your last example, does it define the command \measure just for the next box? And why does my email client display this thread as a reply to the "fit to width by negative letterspacing or narrowing" thread started by Henning? Christoph On 13.06.2011 14:38, Wolfgang Schuster wrote:
Am 13.06.2011 um 14:34 schrieb Wolfgang Schuster:
\starttext
\dowithnextbox {\edef\AlphabetLength{\the\nextboxwd}}% \hbox{abcdefghijklmnopqrstuvwxyz}
\AlphabetLength
\stoptext
Or even better:
\starttext
\dowithnextbox {\definemeasure[alphabetlength][\the\nextboxwd]}% \hbox{abcdefghijklmnopqrstuvwxyz}
\measure{alphabetlength}
\stoptext
Wolfgang
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________
On Mon, Jun 13, 2011 at 2:43 PM, Christoph Redecker
Thanks to both of you, all three suggestions work. However, I don't understand all of the code. What does \dowithnextbox do exactly? do something with the next box In your last example, does it define the command \measure just for the next box? yes
And why does my email client display this thread as a reply to the "fit to width by negative letterspacing or narrowing" thread started by Henning? I don't know. -- luigi
Dear Christoph, Am Montag, den 13.06.2011, 14:43 +0200 schrieb Christoph Redecker: […] please do not top post when the people helping you use interleaved style [1].
And why does my email client display this thread as a reply to the "fit to width by negative letterspacing or narrowing" thread started by Henning?
You used the Reply-To function of your mail client (Thunderbird) instead of creating a new message (by for example clicking on the email address of the ConTeXt list). References: <2BAEF00E-F2AE-4E30-9F86-548BB2A7B918@fiee.net> <4DD261BD.60309@wxs.nl> <23BF6F68-2A11-45A8-936A-1CBA0536CDE0@fiee.net> In-Reply-To: <23BF6F68-2A11-45A8-936A-1CBA0536CDE0@fiee.net> Thanks, Paul [1] http://en.opensuse.org/openSUSE:Mailing_list_netiquette
Am 13.06.2011 um 14:43 schrieb Christoph Redecker:
Thanks to both of you, all three suggestions work. However, I don't understand all of the code. What does \dowithnextbox do exactly?
It’s a high level version of Luigis example. The content of the box with the text “abc…” is saved in the box nextbox which can be accessed with \flushnextbox, the dimensions of the box are available through the command \nextboxht, \nextboxdp and \nextboxwd.
In your last example, does it define the command \measure just for the next box?
\definemeasure is a alternative to dimension and use a macro to store a length. The first argument is the name of the length and you can access the value with the command \measure{<name>} but i forgot to expand the value of the box in my example and it should be: \dowithnextbox {\expanded{\definemeasure[alphabetlength][\the\nextboxwd]}}% \hbox{abcdefghijklmnopqrstuvwxyz} Wolfgang
On 13-6-2011 2:34, Wolfgang Schuster wrote:
Am 13.06.2011 um 14:30 schrieb luigi scarso:
How can I do the same thing in ConTeXt? plain TeX is ok, for example, \newdimen\AlphaBet \bgroup \setbox10=\hbox{abcdefghijklmnopqrstuvwxyz} \global\AlphaBet=\wd10\egroup \the\AlphaBet
\starttext
\dowithnextbox {\edef\AlphabetLength{\the\nextboxwd}}% \hbox{abcdefghijklmnopqrstuvwxyz}
\AlphabetLength
\stoptext
Hans wrote also a command for this but it never went into core: http://archive.contextgarden.net/message/20070314.120612.adab0a8b.en.html
Ok, I'll add it. There will also be an expandable variant (proper typeset but the string must be utf characters only) \starttext \setwidthof{Robin Kirkham}\to\whatever \whatever=\widthofstring{Robin Kirkham} \stoptext ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
participants (6)
-
Christoph Redecker
-
Hans Hagen
-
Henning Hraban Ramm
-
luigi scarso
-
Paul Menzel
-
Wolfgang Schuster