canbedone-periods.tex /size: 6120 b    last modification: 2024-01-16 10:21
1% language=us runpath=texruns:manuals/canbedone
2
3\environment canbedone-style
4
5% \showframe
6
7\startdocument
8  [title=periods,
9   color=middlered]
10
11\startsectionlevel[title=Introduction]
12
13When the \TEX\ program showed up there were not many fonts that could be used so
14it came with its own fonts and because the number of slots in the encoding was
15limited (first to 127, later to 255) there was no space characters. It was not
16needed anyway because the engine uses a model of glue between words. So, instead
17of fixed spacing, \TEX\ uses flexible spacing. In addition to what is normally
18considered a word space, spacing is also determined by the so called space factor
19of characters preceding spaces. But, especially after abbreviations with periods
20you might want something different depending on the usage of the period. Here we
21discuss how that can be done.
22
23\stopsectionlevel
24
25\startsectionlevel[title=Font related spacing]
26
27Spacing is controlled by the amount specified in the font in the so called
28font dimensions. In \CONTEXT\ these can be accessed via macros:
29
30\starttabulate[||c|c|c|c|]
31\BC                        \NC \tf normal space
32                           \NC \bf bold space
33                           \NC \it italic space
34                           \NC \bi bolditalic space                    \NC \NR
35\NC \tex{interwordspace}   \NC {\tf \expandafter}\the\interwordspace
36                           \NC {\bf \expandafter}\the\interwordspace
37                           \NC {\it \expandafter}\the\interwordspace
38                           \NC {\bi \expandafter}\the\interwordspace   \NC \NR
39\NC \tex{interwordstretch} \NC {\tf \expandafter}\the\interwordstretch
40                           \NC {\bf \expandafter}\the\interwordstretch
41                           \NC {\it \expandafter}\the\interwordstretch
42                           \NC {\bi \expandafter}\the\interwordstretch \NC \NR
43\NC \tex{interwordshrink}  \NC {\tf \expandafter}\the\interwordshrink
44                           \NC {\it \expandafter}\the\interwordshrink
45                           \NC {\bi \expandafter}\the\interwordshrink
46                           \NC {\bf \expandafter}\the\interwordshrink  \NC \NR
47\stoptabulate
48
49The differences in the three components are subtle but often of no concern to the
50user. Stretch and shrink kicks in when we align the left and right edge,
51otherwise they are basically ignored. These spacing properties are very specific
52for \TEX\ fonts, they don't come with for instance \OPENTYPE\ fonts. There we
53derive the stretch and shrink from the regular font space (\UNICODE\ slot U+00020
54or \ASCII\ value 32).
55
56A user can tweak the interword spacing with \type {\spaceskip} and \type
57{\xspaceskip} which works together with the \type {\spacefactor} and (character
58specific)\type {\sfcode} values. And as it is somewhat hard to explain the
59details involved I just refer to Chapter~25 (Spacing) of \TEX\ by Topic.
60
61\stopsectionlevel
62
63\startsectionlevel[title=Spacing after periods]
64
65For this manual it's only important to know that the space factors influence the
66spacing after uppercase letters and punctuation and the later aspect is what this
67is about.
68
69\startbuffer[a]
70\frenchspacing          This is a t.e.s.t. for periods. Does it work?
71\vskip-.8\lineheight
72\nonfrenchspacing \blue This is a t.e.s.t. for periods. Does it work?
73\stopbuffer
74
75\startbuffer[b]
76\frenchspacing           This is a t.e.s.t.\ for periods. Does it work?
77\vskip-.8\lineheight
78\nonfrenchspacing \green This is a t.e.s.t.\ for periods. Does it work?
79\stopbuffer
80
81\startbuffer[c]
82\frenchspacing         This is a t.e.s.t\fsp. for periods. Does it work?
83\vskip-.8\lineheight
84\nonfrenchspacing \red This is a t.e.s.t\fsp. for periods. Does it work?
85\stopbuffer
86
87\startbuffer[d]
88\setperiodkerning[zerospaceperiods]
89\frenchspacing         This is a t.e.s.t. for periods. Does it work?
90\vskip-.8\lineheight
91\nonfrenchspacing \red This is a t.e.s.t. for periods. Does it work?
92\stopbuffer
93
94\typebuffer[a] \start \forgetall \resetperiodkerning \getbuffer[a] \stop
95
96You will notice that the spacing after \type {t.e.s.t.} is as flexible as
97the space after \type {periods.} but what if you don't want that? There are
98several ways to influence the following space:
99
100\typebuffer[b] \start \forgetall \resetperiodkerning \getbuffer[b] \stop
101
102The \type {\fsp} macro looks ahead and adapts the space factor:
103
104\typebuffer[c] \start \forgetall \resetperiodkerning \getbuffer[c] \stop
105
106\stopsectionlevel
107
108\startsectionlevel[title=Automation]
109
110Where the manual (explicit) making sure we get spacing right is quite
111robust and predictable a user might be willing to delegate the task to
112\CONTEXT, and here is the trick:
113
114\typebuffer[d] \start \forgetall \resetperiodkerning \getbuffer[d] \stop
115
116This features has been present from mid 2017 but I admit that till now I never
117used it. Reasons are that it makes no sense to adapt existing documents and when
118a text is for instance meant for a user group journal too, you cannot expect this
119automatic feature to be present in the macro package used for typesetting it. But
120maybe it's time to change that policy. I also admit that I seldom have this
121situation, probably the only few cases are abbreviations like \type {e.g.} (for
122example) and \type {c.q.} (casu quo).
123
124There are a few predefined period kerning variants and you can define more if you
125want:
126
127\starttyping
128\defineperiodkerning [zerospaceperiods]  [factor=0]
129\defineperiodkerning [smallspaceperiods] [factor=.25]
130\defineperiodkerning [halfspaceperiods]  [factor=.5]
131\stoptyping
132
133\startbuffer[e]
134\setperiodkerning[zerospaceperiods]
135\frenchspacing         How about c.q. and e.g. within a sentence?
136\vskip-.8\lineheight
137\nonfrenchspacing \red How about c.q. and e.g. within a sentence?
138\stopbuffer
139
140\typebuffer[e] \start \forgetall \getbuffer[e] \stop
141
142Of course one needs to keep an eye on the results because one never knows if the
143heuristics are flawed. And if needed it can be improved.
144
145\stopsectionlevel
146
147\startsectionlevel[title=Todo]
148
149{\em more spacing related features}
150
151% optionalspace
152% autoinsertspace
153% ~
154
155\stopsectionlevel
156
157\stopdocument
158