ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: "Charles P. Schaum" <verbo.solo@sbcglobal.net>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Intraword spacing proof of concept
Date: Thu, 14 Aug 2008 16:24:37 -0500	[thread overview]
Message-ID: <1218749078.12095.30.camel@elbereth> (raw)
In-Reply-To: <48A490AE.4020200@wxs.nl>

Hi all,

Quite a while ago I mentioned letter spacing, or the normal absence
thereof, in TeX and friends. True, you could skin this cat by
mathematically scaling the text (font size) by steps to fit the box ---
the code is out there. But that was not the only way, thought I. Some
programs also call this general idea tracking, that is, inserting
positive or negative kerns independent of the \spacingfactor.

Just for grins I nabbed two snippets from, respectively, manmac.tex and
texbook.tex. I then added a bit of my own hackery that was inspired by
DEK's length macro. I realized that a non-counting version of the length
macro was a memory-friendly way to insert a symbol between any two
others in a given sequence. What I wanted to insert was a negative kern.

The negative kern must be small, less than \negthinspace, or else you
start getting weird effects like a practically chiastic ordering of
letters, and certainly a chaotic one. The smallest that one dare go
seems to be -.066667em, the point where the serifs can start running
together. Using -.033333em really does not show any letters running
together, yet it still saves space. I got those figures as suggested by
Knuth's own selections for tightness in the interword spacing.

And yes, you could theoretically space out the letters, like the soul
package that does proper Sperrdruck. One major drawback with my kludge
is the need to use control spaces, else all spaces evaporate. If soul
were ported to ConTeXt, and it seems like the code might allow that,
then a version that "spaces in" and "spaces out" could well be possible.

So here's the proof of concept, for those so interested.

Charles

\starttext
% macros for non-centered displays
\outer\def\begindisplay{\obeylines\startdisplay}
{\obeylines\gdef\startdisplay#1
  {\catcode`\^^M=5$$#1\halign\bgroup\indent##\hfil&&\qquad##\hfil\cr}}
\outer\def\enddisplay{\crcr\egroup$$}

{\catcode`@=11
\gdef\PackText#1{\@TextPack#1\@end}
\gdef\@TextPack#1{\ifx#1\@end \let\next=\relax \else \let\next=
\@TextPack#1\fi \kern-0.066667em\next}}

\PackText{pack}\par
\PackText{packity\ pack\ pack}\thinspace.

\begindisplay \hbadness10000
\hbox spread-.666667em{The badness of this line is 100.}&
  \quad(very tight)\cr
\hbox spread-.666667em{\PackText{The\ badness\ of\ this\ line\ is\
100}\thinspace.}&
  \quad(\PackText{So\ baaaad}\thinspace!)\cr
\hbox spread-.333333em{The badness of this line is 12.}&
  \quad(somewhat tight)\cr
\hbox{The badness of this line is 0.}&
  \quad(perfect)\cr
\hbox spread.5em{The badness of this line is 12.}&
  \quad(somewhat loose)\cr
%\hbox spread 1em{The badness of this line is 100.}&
% \quad(loose)\cr % then "looser"
\hbox spread 1.259921em{The badness of this line is 200.}&
  \quad(loose)\cr
%\hbox spread 1.713em{The badness of this line is 500.}&
% \quad(bad)\cr % then "worse"
\hbox spread 2.155em{The badness of this line is 1000.}&
  \quad(bad)\cr
\hbox spread 3.684em{The badness of this line is 5000.}& % actually
4995!
  \quad(awful)\cr
\enddisplay
\stoptext


___________________________________________________________________________________
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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


  reply	other threads:[~2008-08-14 21:24 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-13 14:50 Partly OT: some luatex questions Ulrike Fischer
2008-08-13 21:07 ` Arthur Reutenauer
2008-08-14  7:48   ` Ulrike Fischer
2008-08-14  7:58     ` Wolfgang Schuster
2008-08-14  8:11       ` Hans Hagen
2008-08-14 12:25         ` Ulrike Fischer
2008-08-14 14:27           ` Hans Hagen
2008-08-14  9:07       ` Ulrike Fischer
2008-08-14  9:44         ` Wolfgang Schuster
2008-08-14 11:53           ` Ulrike Fischer
2008-08-14 13:49             ` Arthur Reutenauer
2008-08-14 14:28               ` Ulrike Fischer
2008-08-14 20:08                 ` Hans Hagen
2008-08-14 21:24                   ` Charles P. Schaum [this message]
2008-08-15  7:49                     ` Intraword spacing proof of concept Hans Hagen
2008-08-15 15:50                       ` Charles P. Schaum
2008-08-15 17:40                         ` AUCTeX issues not necessarily ConTeXt-related Charles P. Schaum
2008-08-15 20:53                           ` Peter Münster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1218749078.12095.30.camel@elbereth \
    --to=verbo.solo@sbcglobal.net \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).