summaryrefslogtreecommitdiff
path: root/doc/context/sources/general/manuals/canbedone/canbedone-periods.tex
blob: 3ddb4545c307c90971ec19c26bd8c7c227d6007b (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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
% language=us runpath=texruns:manuals/canbedone

\environment canbedone-style

% \showframe

\startdocument
  [title=periods,
   color=middlered]

\startsectionlevel[title=Introduction]

When the \TEX\ program showed up there were not many fonts that could be used so
it came with its own fonts and because the number of slots in the encoding was
limited (first to 127, later to 255) there was no space characters. It was not
needed anyway because the engine uses a model of glue between words. So, instead
of fixed spacing, \TEX\ uses flexible spacing. In addition to what is normally
considered a word space, spacing is also determined by the so called space factor
of characters preceding spaces. But, especially after abbreviations with periods
you might want something different depending on the usage of the period. Here we
discuss how that can be done.

\stopsectionlevel

\startsectionlevel[title=Font related spacing]

Spacing is controlled by the amount specified in the font in the so called
font dimensions. In \CONTEXT\ these can be accessed via macros:

\starttabulate[||c|c|c|c|]
\BC                        \NC \tf normal space
                           \NC \bf bold space
                           \NC \it italic space
                           \NC \bi bolditalic space                    \NC \NR
\NC \tex{interwordspace}   \NC {\tf \expandafter}\the\interwordspace
                           \NC {\bf \expandafter}\the\interwordspace
                           \NC {\it \expandafter}\the\interwordspace
                           \NC {\bi \expandafter}\the\interwordspace   \NC \NR
\NC \tex{interwordstretch} \NC {\tf \expandafter}\the\interwordstretch
                           \NC {\bf \expandafter}\the\interwordstretch
                           \NC {\it \expandafter}\the\interwordstretch
                           \NC {\bi \expandafter}\the\interwordstretch \NC \NR
\NC \tex{interwordshrink}  \NC {\tf \expandafter}\the\interwordshrink
                           \NC {\it \expandafter}\the\interwordshrink
                           \NC {\bi \expandafter}\the\interwordshrink
                           \NC {\bf \expandafter}\the\interwordshrink  \NC \NR
\stoptabulate

The differences in the three components are subtle but often of no concern to the
user. Stretch and shrink kicks in when we align the left and right edge,
otherwise they are basically ignored. These spacing properties are very specific
for \TEX\ fonts, they don't come with for instance \OPENTYPE\ fonts. There we
derive the stretch and shrink from the regular font space (\UNICODE\ slot U+00020
or \ASCII\ value 32).

A user can tweak the interword spacing with \type {\spaceskip} and \type
{\xspaceskip} which works together with the \type {\spacefactor} and (character
specific)\type {\sfcode} values. And as it is somewhat hard to explain the
details involved I just refer to Chapter~25 (Spacing) of \TEX\ by Topic.

\stopsectionlevel

\startsectionlevel[title=Spacing after periods]

For this manual it's only important to know that the space factors influence the
spacing after uppercase letters and punctuation and the later aspect is what this
is about.

\startbuffer[a]
\frenchspacing          This is a t.e.s.t. for periods. Does it work?
\vskip-.8\lineheight
\nonfrenchspacing \blue This is a t.e.s.t. for periods. Does it work?
\stopbuffer

\startbuffer[b]
\frenchspacing           This is a t.e.s.t.\ for periods. Does it work?
\vskip-.8\lineheight
\nonfrenchspacing \green This is a t.e.s.t.\ for periods. Does it work?
\stopbuffer

\startbuffer[c]
\frenchspacing         This is a t.e.s.t\fsp. for periods. Does it work?
\vskip-.8\lineheight
\nonfrenchspacing \red This is a t.e.s.t\fsp. for periods. Does it work?
\stopbuffer

\startbuffer[d]
\setperiodkerning[zerospaceperiods]
\frenchspacing         This is a t.e.s.t. for periods. Does it work?
\vskip-.8\lineheight
\nonfrenchspacing \red This is a t.e.s.t. for periods. Does it work?
\stopbuffer

\typebuffer[a] \start \forgetall \resetperiodkerning \getbuffer[a] \stop

You will notice that the spacing after \type {t.e.s.t.} is as flexible as
the space after \type {periods.} but what if you don't want that? There are
several ways to influence the following space:

\typebuffer[b] \start \forgetall \resetperiodkerning \getbuffer[b] \stop

The \type {\fsp} macro looks ahead and adapts the space factor:

\typebuffer[c] \start \forgetall \resetperiodkerning \getbuffer[c] \stop

\stopsectionlevel

\startsectionlevel[title=Automation]

Where the manual (explicit) making sure we get spacing right is quite
robust and predictable a user might be willing to delegate the task to
\CONTEXT, and here is the trick:

\typebuffer[d] \start \forgetall \resetperiodkerning \getbuffer[d] \stop

This features has been present from mid 2017 but I admit that till now I never
used it. Reasons are that it makes no sense to adapt existing documents and when
a text is for instance meant for a user group journal too, you cannot expect this
automatic feature to be present in the macro package used for typesetting it. But
maybe it's time to change that policy. I also admit that I seldom have this
situation, probably the only few cases are abbreviations like \type {e.g.} (for
example) and \type {c.q.} (casu quo).

There are a few predefined period kerning variants and you can define more if you
want:

\starttyping
\defineperiodkerning [zerospaceperiods]  [factor=0]
\defineperiodkerning [smallspaceperiods] [factor=.25]
\defineperiodkerning [halfspaceperiods]  [factor=.5]
\stoptyping

\startbuffer[e]
\setperiodkerning[zerospaceperiods]
\frenchspacing         How about c.q. and e.g. within a sentence?
\vskip-.8\lineheight
\nonfrenchspacing \red How about c.q. and e.g. within a sentence?
\stopbuffer

\typebuffer[e] \start \forgetall \getbuffer[e] \stop

Of course one needs to keep an eye on the results because one never knows if the
heuristics are flawed. And if needed it can be improved.

\stopsectionlevel

\startsectionlevel[title=Todo]

{\em more spacing related features}

% optionalspace
% autoinsertspace
% ~

\stopsectionlevel

\stopdocument