-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtods.html
412 lines (326 loc) · 12 KB
/
tods.html
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
<!DOCTYPE html>
<html lang="en-GB">
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Typographic and Opentype Default Stylesheet (TODS)</title>
<link href="tods.css" rel="stylesheet" id="tods-css" />
<style>
/*
1. Reset
*/
html {
-moz-text-size-adjust: none;
-webkit-text-size-adjust: none;
text-size-adjust: none;
}
body, h1, h2, h3, h4, h5, h6, address, p, hr, pre, blockquote, ol, ul, li, dl, dt, dd, figure, figcaption, div, table, caption, form, fieldset {
margin: 0;
}
input,
button,
textarea,
select {
font-family: inherit;
font-size: inherit;
}
/*
2. Web fonts
*/
@font-face {
font-family: 'Literata';
src: url('Literata-var.woff2') format('woff2') tech(variations),
url('Literata-var.woff2') format('woff2-variations');
font-weight: 1 1000;
font-stretch: 50% 200%;
font-style: normal;
font-display: fallback;
}
@font-face {
font-family: 'Literata';
src: url('Literata-Italic-var.woff2') format('woff2') tech(variations),
url('Literata-Italic-var.woff2') format('woff2-variations');
font-weight: 1 1000;
font-stretch: 50% 200%;
font-style: italic;
font-display: swap;
}
@font-face {
font-family: "RobotoFlex";
src: url("RobotoFlex.woff2") format('woff2') tech(variations),
url("RobotoFlex.woff2") format('woff2-variations');
font-weight: 1 1000;
font-stretch: 50% 200%;
font-style: normal;
font-display: block;
}
@font-face {
font-family: "Bookmania";
src: url("bookmania-blackitalic.woff2") format('woff2');
font-weight: 900;
font-style: italic;
font-display: block;
}
@font-face {
font-family: "Bookmania";
src: url("bookmania-bold.woff2") format('woff2');
font-weight: 700;
font-style: normal;
font-display: block;
}
.flow > * + * {
margin-block-start: var(--flow-space, 1.5em);
}
/* Fluid type sizing.
@link https://utopia.fyi/type/calculator?c=320,17,1.2,1240,21,1.333,4,1,&s=0.75|0.5|0.25,1.5|2|3|4|6,s-l&g=s,l,xl,12 */
:root {
--step--1: clamp(0.8854rem, 0.8509rem + 0.1725vw, 0.9846rem);
--step-0: clamp(1.0625rem, 0.9755rem + 0.4348vw, 1.3125rem);
--step-1: clamp(1.275rem, 1.1099rem + 0.8253vw, 1.7496rem);
--step-2: clamp(1.53rem, 1.251rem + 1.3951vw, 2.3322rem);
--step-3: clamp(1.836rem, 1.3933rem + 2.2135vw, 3.1088rem);
--step-4: clamp(2.2032rem, 1.5281rem + 3.3753vw, 4.144rem);
}
body {
margin-inline: 3vw;
line-height: 1.5;
font-family: "Literata", ui-serif, serif;
font-size: var(--step-0);
}
h1, h2, h3, h4 {
line-height: 1.1;
}
h1 {
font-size: var(--step-4);
}
h2 {
font-size: var(--step-2);
}
h3 {
font-size: var(--step-1);
}
.flow {
max-inline-size: calc(36 * var(--step-0));
margin-inline: auto;
margin-block: 3em;
}
.flow h1 {
margin-inline: calc(-1 * (48vw - 50%)); /* create negative margins to expand heading outside of prose block */
}
.flow h1 + p {
--flow-space: 3em;
}
.flow h2 + p, .flow h3 + p {
--flow-space: 0.75em;
}
blockquote {
margin-inline-start: 1lh;
}
code {
font-family: "Inconsolata", ui-monospace, monospace;
}
table {
border-collapse: collapse;
}
tbody {
border-top: 0.125em solid #ddd;
border-bottom: 0.125em solid #ddd;
}
th, td {
padding: .25em .75em;
vertical-align: top;
text-align: left;
border-bottom: 0.0625em solid #ddd;
}
th:first-child, td:first-child {
padding-left: 0.25em;
}
th:last-child, td:last-child {
padding-right: 0.25em;
}
td.nums, th.nums, tr.nums th, tr.nums td {
text-align: right;
}
.bookmania {
font-family: "Bookmania", ui-serif, serif;
font-size: var(--step-4);
}
.bookmania + .bookmania {
--flow-space: 0em;
}
.bookmania1 {
font-weight:900;
font-style: italic;
}
.bookmania2 {
font-weight:700;
font-style: normal;
}
@font-feature-values "Bookmania" {
@swash {
bottom-right-swash-short: 17;
top-right-swash-long: 20;
}
}
@font-feature-values "Bookmania" {
@styleset {
bottom-left-swash-long: 16;
bottom-right-swash-long: 18;
bottom-right-swash-combo: 17 18;
top-swashes-bottom-left-swash-combo: 10 14 19;
}
}
.swsh17 { font-variant-alternates: swash(bottom-right-swash-short); }
.swsh20 { font-variant-alternates: swash(top-right-swash-long); }
.ss16 { font-variant-alternates: styleset(bottom-left-swash-long); }
.ss18 { font-variant-alternates: styleset(bottom-right-swash-long); }
.ss17-18 { font-variant-alternates: styleset(bottom-right-swash-combo); }
.ss10-14-19 { font-variant-alternates: styleset(top-swashes-bottom-left-swash-combo); }
.gradecompare {
display: flex;
gap:0.5em;
font-family: "RobotoFlex", ui-sans-serif, sans-serif;
}
.gradecompare div {
flex-basis: 50%;
padding-inline:1em;
padding-block:0.5em;
border: 3px solid #000;
}
.inverted {
background:#000;
color: #fff;
}
.spam {
--flow-space: 0;
font-size: var(--step--1);
font-variation-settings: "OPSZ" 7, "opsz" 7;
}
.toggle-form {
font-family: ui-sans-serif, sans-serif;
background:#ddd;
color: #000;
position: fixed;
top: 0;
left: 0;
width: 100%;
padding-block:0.5em;
}
.toggle-form form {
display: flex;
gap:0.25em;
justify-content: center;
line-height: 1.1;
}
.toggle-form label {
font-size: var(--step--1);
}
footer p {
padding-top: 80vh;
padding-bottom: 2em;
font-size: var(--step--1);
text-align:center;
}
</style>
<body>
<div class="toggle-form">
<form>
<label for="tods-switch">Toggle TODS</label>
<input type="checkbox" checked switch id="tods-switch" />
</form>
</div>
<div class="prose flow">
<h1 class="centered">Typographic and Opentype Default Stylesheet (TODS)</h1>
<p>The concept is that <abbr class="smallcaps">TODS</abbr> sets sensible typographic defaults for use on prose (a column of text like this one). For full details see the <a href="https://github.com/clagnut/TODS">readme in the Github repo</a>. The page you’re reading uses fairly random bits of text to demonstrate most aspects of <abbr class="smallcaps">TODS</abbr>, which you can toggle on and off.</p>
<p><em>This page could be much better and is missing some stuff, such as dark mode. Feel free to branch and edit.</em></p>
<h2>1440 ‒ 1500, the Incunabula</h2>
<p>The word incunabula comes from the Latin cunae, meaning <q>cradle.</q> It can describe the earliest stages in the development of anything, but it has come to stand particularly for those books produced before 1500. The meagre information about Gutenberg and his works at the time of his death has not been substantially added to since.</p>
<h3>The 42-line bible</h3>
<p>By 1448 he had returned to Mainz and had obtained a loan of 150 gulden from a relative there. This was insufficient for his needs since he was again seeking financial backing only two years later. This time he borrowed 800 gulden, at 6 per cent interest, from Johann Fust.</p>
<h2>The job of typography</h2>
<p>The revered type designer Hermann Zapf said that, for designers, <q>typographic design is sometimes misconstrued as a form of private self-expression</q><sup>(2)</a></sup>. Typography is not art – it is craft and design with purpose. It is there to perform a service for the reader. Quoting another great designer, Emil Ruder said in 1969<sup>(3)</sup>:</p>
<blockquote class="quoted">
<p>Typography has one plain duty before it and that is to convey information in writing. No argument or consideration can absolve typography from this duty. A printed work which cannot be read becomes a product without purpose.</p>
</blockquote>
<p>A website which cannot be read is a product without purpose. Typography’s chief role is to ensure legibility and readability, but that’s not its only job. Typography should invite the reader into the text.</p>
<h2>Positional numeral systems</h2>
<p>In any standard positional numeral system, a number is conventionally written as (x)<sub>y</sub> with x as the string of digits and y as its base. For example, comparing values in hexadecimal, decimal, and octal one might write <span class="lnum">C<sub>12</sub>=12<sub>10</sub>=14<sub>8</sub></span>. Alternatively you could abbreviate like this: <span class="lnum">C<sub>hex</sub>=12<sub>dec</sub>=14<sub>oct</sub></span>.</p>
<h3>Caffeine</h3>
<p>Caffeine is a central nervous system <abbr class="smallcaps">(CNS)</abbr> stimulant of the <code>methylxanthine</code> class. Its chemical formula is C<sub>10</sub>H<sub>16</sub>N<sub>5</sub>O<sub>13</sub>P<sub>3</sub>, which you should really typeset using scientific inferiors instead of subscripts: <span class="sinf">C10H16N5O13P3</span>.</p>
<h3>Populations</h3>
<p>Here is recent data on some European countries.</p>
<table class="ex-alignment">
<thead>
<tr><th>Country</th><th class='nums'>Area</th><th class='nums'>Population</th><th class='nums'>GDP</th><th>Capital</th></tr>
</thead>
<tbody>
<tr><td>Austria</td><td class='nums'>83,858</td><td class='nums'>8,169,929</td><td class='nums'>339</td><td>Vienna</td></tr>
<tr><td>Belgium</td><td class='nums'>30,528</td><td class='nums'>11,007,000</td><td class='nums'>410</td><td>Brussels</td></tr>
<tr><td>Denmark</td><td class='nums'>43,094</td><td class='nums'>5,564,219</td><td class='nums'>271</td><td>Copenhagen</td></tr>
<tr><td>France</td><td class='nums'>547,030</td><td class='nums'>66,104,000</td><td class='nums'>2,181</td><td>Paris</td></tr>
<tr><td>Germany</td><td class='nums'>357,021</td><td class='nums'>80,716,000</td><td class='nums'>3,032</td><td>Berlin</td></tr>
<tr><td>Greece</td><td class='nums'>131,957</td><td class='nums'>11,123,034</td><td class='nums'>176</td><td>Athens</td></tr>
</tbody>
</table>
<h2 class="bookmania bookmania1">Chicken</h2>
<h2 class="bookmania bookmania1 dlig">Chic<span class="swsh17">k</span>e<span class="ss17-18">n</span></h2>
<h2 class="bookmania bookmania2">Huevos</h2>
<h2 class="bookmania bookmania2"><span class="ss10-14-19">H</span>ue<span class="swsh20">v</span>o<span class="ss16">s</span></h2>
<p>The heading above should be made up of contextual ligatures, discretionary ligatures and various swashes.</p>
<h2>Colophon</h2>
<p>The fonts used on the page are <a href="">Literata</a>, <a href="">Roboto Flex</a> and <a href="">Bookmania</a>.</p>
<p>As of <time data-js="clock" datetime="00:00:00">00:00:00</time> we had <span data-js="counter" class="tnum">1000</span> likes.</p>
<p class="uppercase spam">SEND YOUR SPAM TO [email protected] (NO DUCK-PICS PLS).</p>
<div class="gradecompare">
<div>
<h2>Heading</h2>
<p>Each opening or closing quote is replaced by one of the strings from the value of quotes</p>
</div>
<div class="inverted">
<h2>Heading</h2>
<p>Each opening or closing quote is replaced by one of the strings from the value of quotes</p>
</div>
</div>
</div>
<footer><p>The above space is intentionally left blank.</p></footer>
<script>
// Borrowed from https://codepen.io/barthendrix/pen/gOJXRRe with thanks
function showTime() {
const clock = document.querySelector('[data-js="clock"]');
if(!clock) return;
const date = new Date();
const hour = date.getHours(); // 0 - 23
const minute = date.getMinutes(); // 0 - 59
const second = date.getSeconds(); // 0 - 59
const time = `${doubleDigits(hour)}:${doubleDigits(minute)}:${doubleDigits(second)}`;
clock.innerText = time;
clock.dateTime = time;
}
function animateCounter () {
const counter = document.querySelector('[data-js="counter"]');
if(!counter) return;
let curValue = parseInt(counter.innerHTML);
setInterval(() => {
curValue ++;
counter.innerText = curValue.toString();
}, 50);
}
function doubleDigits(value) {
return value = (value < 10) ? `0${value}` : value;
}
function enableStyleToggle() {
const todsToggle = document.getElementById('tods-switch');
const todsLink = document.getElementById('tods-css');
if(!todsToggle || !todsLink) return;
if(!todsToggle.checked) {
todsLink.removeAttribute("disabled");
}
todsToggle.addEventListener('change', () => {
todsLink.toggleAttribute("disabled");
})
}
setInterval(showTime, 1000);
animateCounter();
enableStyleToggle();
</script>
</body>
</html>