summaryrefslogtreecommitdiff
path: root/systems/tex-extensions/clasen/hz/hz.tex
blob: 3ff443226142500e574a555b47ea8d3eada8b212 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
\documentclass[preprint]{ltugboat}
\usepackage{shortvrb}
\usepackage{url}

\providecommand{\meta}[1]{\ensuremath{\langle\textit{#1}\rangle}}
\makeatletter
\providecommand{\eTeX}{$\m@th\varepsilon$-\TeX}
\makeatother
\hyphenation{pa-ra-me-ter}

\emergencystretch=4mm
\overfullrule=0pt
\title{Why \TeX\ can't set the Gutenberg bible}
\author{Matthias Clasen}
%\address{}
\netaddress{maclas@gmx.de}
\setcounter{page}{1}

\begin{document}
\maketitle
\MakeShortVerb{\|}

\section{Introduction}

\TeX's paragraph breaking algorithm is one of its virtues. It usually
achieves a fairly uniform grey value throughout the page. If it can't achieve 
completely uniform spacing, the excess space is distributed among the
interword spaces in the line. 

Thus \TeX\ doesn't use one technique for uniform spacing which was invented
as far back as Gutenberg: variation of the letter width to make up excess
space. 

I propose a minimalist extension of \TeX\ to enable it to use letters of
variable width. The extension is to associate \textit{variants} with 
fonts. If \TeX\ is about to set character~|c| from font~|f|, it looks for 
character~|c| in all variants associated with~|f| and chooses the one 
which ``fits best in the current situation''. I.\,e.\ in a tight line,
a narrow variant will be chosen, while a wide variant would be preferable 
in a loose line. The variability of the character width also influences the
calculation of the badness during the paragraph breaking. This is the true 
strength of the extension: like |\emergencystretch|, it adds flexibility
during paragraph breaking and thus increases the number of feasible
breakpoints, but without tearing ugly holes in the shape of the paragraph. 

I call this a minimalist extension, because it completely ignores the
questions of suitable font technology for automatic generation of font
variants from existing fonts. From the point of view taken here, font
variants are just separate |tfm| files which are only required to contain
characters in the same positions. Furthermore \TeX\ assumes that the
widths vary consistently between the variants, i.\,e.\ if variant~|f|
contains \emph{one} character which is wider than the corresponding
character in variant~|f'|, then \emph{all} characters from~|f| should
be at least as wide as their counterparts in~|f'|.  
 
\section{Implementation}

The changes to \TeX{} the program sketched above are realized in the
change file |hz.ch|. It implements the new primitive
\[\cs{fontvariant}\meta{font$_1$}=\meta{font$_2$}\]
which declares \meta{font$_2$} to be a variant of \meta{font$_1$} 
(where \meta{font$_1$} and \meta{font$_2$} must be font identifiers).
Font variants can only be removed \textit{en bloc}, by using
|\nullfont| as \meta{font$_2$}.

\TeX\ will use the fontvariants and allow the |\fontvariant| primitive only
when the new integer parameter |\hzstate| has a positive value. Setting
|\hzstate| to zero does \emph{not} remove the font variants previously 
declared. 

\TeX\ uses the font variants only when it looks for the width of a character.
All other |tfm| informations, in particular kerning and ligaturing, are always
taken from the base font. 

\section{Installation}
 
 The change files are written for \TeX~3.1459. But it should need only
 cosmetic changes to get them to work with other versions of \TeX3.

 To make the change files for \TeX{} work, you have to apply the change file
 |pre.ch| first. I have only tried these files with |web2c|, and
 for that you need to surround the |web2c| change file with |pre-web2c.ch| and
 |post-web2c.ch|. You also need the additional change file 
 |hz-post-web2c.ch|. If you want to use this change together with the
 change for fixed-point arithmetic (|glue.ch|), then you also need
 the file |hz-glue.ch|.

 All this boils down to the command line

\begin{verbatim}
mv tex.ch tex.ch.orig
tie -c tex.ch tex.web pre.ch hz.ch \ 
       hz-glue.ch pre-web2c.ch \
       tex.ch.orig post-web2c.ch \
       hz-post-web2c.ch 
\end{verbatim}

 \makesignature

 \bibliographystyle{plain}
 \bibliography{etex}

\end{document}