ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* fit to width by negative letterspacing or narrowing
@ 2011-05-17 11:25 Henning Hraban Ramm
  2011-05-17 11:53 ` Hans Hagen
  0 siblings, 1 reply; 12+ messages in thread
From: Henning Hraban Ramm @ 2011-05-17 11:25 UTC (permalink / raw)
  To: mailing ConTeXt users list for

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)

___________________________________________________________________________________
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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: fit to width by negative letterspacing or narrowing
  2011-05-17 11:25 fit to width by negative letterspacing or narrowing Henning Hraban Ramm
@ 2011-05-17 11:53 ` Hans Hagen
  2011-05-18  7:41   ` Henning Hraban Ramm
  0 siblings, 1 reply; 12+ messages in thread
From: Hans Hagen @ 2011-05-17 11:53 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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
-----------------------------------------------------------------
___________________________________________________________________________________
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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: fit to width by negative letterspacing or narrowing
  2011-05-17 11:53 ` Hans Hagen
@ 2011-05-18  7:41   ` Henning Hraban Ramm
  2011-06-13 12:15     ` measuring alphabet length Christoph Redecker
  0 siblings, 1 reply; 12+ messages in thread
From: Henning Hraban Ramm @ 2011-05-18  7:41 UTC (permalink / raw)
  To: mailing list for ConTeXt users


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)

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 12+ messages in thread

* measuring alphabet length
  2011-05-18  7:41   ` Henning Hraban Ramm
@ 2011-06-13 12:15     ` Christoph Redecker
  2011-06-13 12:30       ` luigi scarso
  0 siblings, 1 reply; 12+ messages in thread
From: Christoph Redecker @ 2011-06-13 12:15 UTC (permalink / raw)
  To: ntg-context

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
___________________________________________________________________________________
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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: measuring alphabet length
  2011-06-13 12:15     ` measuring alphabet length Christoph Redecker
@ 2011-06-13 12:30       ` luigi scarso
  2011-06-13 12:34         ` Wolfgang Schuster
  0 siblings, 1 reply; 12+ messages in thread
From: luigi scarso @ 2011-06-13 12:30 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Mon, Jun 13, 2011 at 2:15 PM, Christoph Redecker
<christoph.redecker@tu-harburg.de> wrote:
> 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
___________________________________________________________________________________
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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: measuring alphabet length
  2011-06-13 12:30       ` luigi scarso
@ 2011-06-13 12:34         ` Wolfgang Schuster
  2011-06-13 12:38           ` Wolfgang Schuster
  2011-06-15  9:29           ` Hans Hagen
  0 siblings, 2 replies; 12+ messages in thread
From: Wolfgang Schuster @ 2011-06-13 12:34 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 554 bytes --]


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


[-- Attachment #1.2: Type: text/html, Size: 1074 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: measuring alphabet length
  2011-06-13 12:34         ` Wolfgang Schuster
@ 2011-06-13 12:38           ` Wolfgang Schuster
  2011-06-13 12:43             ` Christoph Redecker
  2011-06-15  9:29           ` Hans Hagen
  1 sibling, 1 reply; 12+ messages in thread
From: Wolfgang Schuster @ 2011-06-13 12:38 UTC (permalink / raw)
  To: mailing list for ConTeXt users


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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: measuring alphabet length
  2011-06-13 12:38           ` Wolfgang Schuster
@ 2011-06-13 12:43             ` Christoph Redecker
  2011-06-13 12:59               ` luigi scarso
                                 ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Christoph Redecker @ 2011-06-13 12:43 UTC (permalink / raw)
  To: ntg-context

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
> ___________________________________________________________________________________
___________________________________________________________________________________
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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: measuring alphabet length
  2011-06-13 12:43             ` Christoph Redecker
@ 2011-06-13 12:59               ` luigi scarso
  2011-06-13 13:02               ` netiquette (was: measuring alphabet length) Paul Menzel
  2011-06-13 13:14               ` measuring alphabet length Wolfgang Schuster
  2 siblings, 0 replies; 12+ messages in thread
From: luigi scarso @ 2011-06-13 12:59 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Mon, Jun 13, 2011 at 2:43 PM, Christoph Redecker
<christoph.redecker@tu-harburg.de> wrote:
> 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
___________________________________________________________________________________
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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 12+ messages in thread

* netiquette (was: measuring alphabet length)
  2011-06-13 12:43             ` Christoph Redecker
  2011-06-13 12:59               ` luigi scarso
@ 2011-06-13 13:02               ` Paul Menzel
  2011-06-13 13:14               ` measuring alphabet length Wolfgang Schuster
  2 siblings, 0 replies; 12+ messages in thread
From: Paul Menzel @ 2011-06-13 13:02 UTC (permalink / raw)
  To: ntg-context


[-- Attachment #1.1: Type: text/plain, Size: 826 bytes --]

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

[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: measuring alphabet length
  2011-06-13 12:43             ` Christoph Redecker
  2011-06-13 12:59               ` luigi scarso
  2011-06-13 13:02               ` netiquette (was: measuring alphabet length) Paul Menzel
@ 2011-06-13 13:14               ` Wolfgang Schuster
  2 siblings, 0 replies; 12+ messages in thread
From: Wolfgang Schuster @ 2011-06-13 13:14 UTC (permalink / raw)
  To: mailing list for ConTeXt users


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

___________________________________________________________________________________
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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: measuring alphabet length
  2011-06-13 12:34         ` Wolfgang Schuster
  2011-06-13 12:38           ` Wolfgang Schuster
@ 2011-06-15  9:29           ` Hans Hagen
  1 sibling, 0 replies; 12+ messages in thread
From: Hans Hagen @ 2011-06-15  9:29 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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
-----------------------------------------------------------------
___________________________________________________________________________________
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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2011-06-15  9:29 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-17 11:25 fit to width by negative letterspacing or narrowing Henning Hraban Ramm
2011-05-17 11:53 ` Hans Hagen
2011-05-18  7:41   ` Henning Hraban Ramm
2011-06-13 12:15     ` measuring alphabet length Christoph Redecker
2011-06-13 12:30       ` luigi scarso
2011-06-13 12:34         ` Wolfgang Schuster
2011-06-13 12:38           ` Wolfgang Schuster
2011-06-13 12:43             ` Christoph Redecker
2011-06-13 12:59               ` luigi scarso
2011-06-13 13:02               ` netiquette (was: measuring alphabet length) Paul Menzel
2011-06-13 13:14               ` measuring alphabet length Wolfgang Schuster
2011-06-15  9:29           ` Hans Hagen

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).