-
Notifications
You must be signed in to change notification settings - Fork 69
/
Copy pathindex.html
291 lines (197 loc) · 8.25 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<meta name="author" content="Nathan Ford" />
<meta name="description" content="Typography tools for better web type. Type.js allows you to write new CSS properties to take finer typographic control of type styles on the web." />
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0" />
<title>type.js</title>
<link href='http://fonts.googleapis.com/css?family=Droid+Sans+Mono' rel='stylesheet' type='text/css'>
<link href="./css/styles.css" rel="stylesheet" />
</head>
<body>
<div id="toggler">See it in action: <a id="toggle" rel="on" href="#">Turn off type.js</a></div>
<header id="site-header">
<h1>type.js</h1>
<h2>Typography tools for better web type.</h2>
<p>Type.js allows you to write <a href="#properties">new CSS properties</a> to take finer typographic control of type styles on the web.</p>
</header>
<section id="implementation">
<div id="download" class="box clearfix">
<a class="button" href="https://github.com/nathanford/type.js">Grab type.js on GitHub</a>
<p class="detail">Latest version: 1.0</p>
</div>
<h2>Implementation</h2>
<p>Set up is simple. Upload <code>type.js</code> to your site, and link it in your HTML, just before the end of the <code>body</code>.</p>
<figure>
<pre><script src="./type.js" type="text/javascript"></script></pre>
</figure>
<p>Next, add a <code>style</code> tag before the <code>script</code>, and write these new CSS properties just like you would any other styles. This is a good start:</p>
<figure>
<pre><style>
body {
min-font-size: 16px;
}
p, li, dd {
rag-adjust: small-words;
widow-adjust: padding-right;
}
</style>
<script src="./type.js" type="text/javascript"></script></pre>
</figure>
<p><strong>Note:</strong> These new properties will only work with on-page CSS in a <code>style</code> tag. Styles in external CSS files, or inline-styles will not be recognized, <a href="#issues">for now</a>.</p>
</section>
<section id="examples">
<h2>Examples</h2>
<p>This whole page is an example! Inspect away to see how it works.</p>
</section>
<section id="properties">
<h2>Properties</h2>
<h3 id="kerning-pairs">Kerning Pairs</h3>
<p>Manually adjust the space between two specific glyphs with a simple syntax. Read more <a href="http://artequalswork.com/posts/manual-kerning/" title="A Manual Kerning Method for the Web on Art=Work">about manual kerning</a> here.</p>
<h4>Properties</h4>
<p><code>kerning-pairs</code> accepts a comma separated list of two glyphs, then the distance you want between them. Accepts positive or negative distances.</p>
<figure>
<pre>kerning-pairs: az 0.02em;</pre>
</figure>
<h4>Values</h4>
<p><code>{Any glyph}{Any glyph} {Any distance}{Any CSS unit}</code></p>
<h4>Example CSS</h4>
<figure>
<pre>h1 {
font-size: 3em;
line-height: 1.2;
kerning-pairs: az 0.02em,
zy 0.01em,
th 0.01em,
ov -0.02em;
}</pre>
</figure>
<h3 id="rag-adjust">Rag Adjust</h3>
<p>Set rules for where lines will to break in a paragraph. Read more <a href="http://24ways.org/2013/run-ragged/" title="Run Ragged on 24 ways">about rag rules</a> here.</p>
<h4>Properties</h4>
<p><code>rag-adjust</code> accepts four values that describe where your lines should break.</p>
<figure>
<pre>rag-adjust: small-words;</pre>
</figure>
<h4>Values</h4>
<ul>
<li><p><code>emphasis</code> – Text of three or less words in bold or italics does not break across lines.</p></li>
<li><p><code>small-words</code> – Breaks lines before words of three or less characters.</p></li>
<li><p><code>prepositions</code> – Breaks lines before prepositions. (English language only, for now.)</p></li>
<li><p><code>dashes</code> – Breaks lines before hyphens and dashes.</p></li>
<li><p><code>all</code> – Breaks lines before all of the above.</p></li>
</ul>
<h4>Example CSS</h4>
<figure>
<pre>p, li, h3, dd {
max-width: 35em;
rag-adjust: small-words;
}</pre>
</figure>
<h3 id="widow-adjust">Widow Adjust</h3>
<p>Set rules for eliminating widows – or any grouping of less than 14 characters on the last line of a paragraph. Read more <a href="http://artequalswork.com/posts/on-widows/" title="On Widows, and How to Tame Them on Art=Work">about fixing widows</a> here.</p>
<h4>Properties</h4>
<p><code>widow-adjust</code> accepts the style property you want to use to fix your paragraph.</p>
<figure>
<pre>widow-adjust: padding-right;</pre>
</figure>
<h4>Values</h4>
<ul>
<li><p><code>padding-right</code> – Increases <code>padding-right</code> until the widow is fixed. (Using <code>box-sizing:border-box;</code>)</p></li>
<li><p><code>padding-left</code> – Increases <code>padding-left</code> until the widow is fixed. (Using <code>box-sizing:border-box;</code>)</p></li>
<li><p><code>word-spacing</code> – Removes <code>word-spacing</code> until the widow is fixed.</p></li>
<li><p><code>non-breaking-space</code> – Adds a non-breaking space character (<code> </code>) between the last two words of the paragraph.</p></li>
</ul>
<h4>Example CSS</h4>
<figure>
<pre>p, li, h3, dd {
max-width: 35em;
widow-adjust: padding-right;
}</pre>
</figure>
<h3 id="min-max-font-size">Min/max font-size</h3>
<p>Set a minimum and maximum font-size for text when using a viewport unit for <code>font-size</code>.</p>
<h4>Properties</h4>
<p><code>min-font-size</code> and <code>max-font-size</code> accepts any <code>font-size</code> value and CSS unit. Does not accept viewport units.</p>
<figure>
<pre>min-font-size: 20px;</pre>
</figure>
<h4>Values</h4>
<p><code>{Any value}{Any css unit}</code></p>
<h4>Example CSS</h4>
<figure>
<pre>h1 {
font-size: 4vw;
max-font-size: 50px;
min-font-size: 30px;
}</pre>
</figure>
</section>
<section id="issues">
<h2>Issues</h2>
<p>Type.js only works within <code>style</code> tags on a page. For now. You can try using your external stylesheets by changing an option in the <code>Type.js</code> file. Change:</p>
<figure>
<pre>stylefill.options({
externalCSS : false
});</pre>
</figure>
<p>…to:</p>
<figure>
<pre>stylefill.options({
externalCSS : true
});</pre>
</figure>
<p><strong>Note:</strong> This will cause the browser to download your external CSS files twice. Once, as per usual, and again to read the <code>Type.js</code> property values.</p>
<p>You can <a href="https://github.com/nathanford/type.js/issues" title="View issues">discuss this and more issues on GitHub</a>.</p>
</section>
<footer id="site-footer">
<p>Created by Nathan Ford of <a href="http://artequalswork.com" title="Visit Art=Work">Art=Work</a>. Bother me on Twitter: <a href="http://twitter.com/nathan_ford">@nathan_ford</a></p>
</footer>
<style>
body {
min-font-size: 12px;
}
h1 {
kerning-pairs: ty -0.05em,
pe -0.01em,
e. -0.18em,
.j -0.28em,
js -0.1em;
}
#site-header h2 {
widow-adjust: non-breaking-space;
}
p, li {
rag-adjust: small-words;
widow-adjust: padding-right;
}
</style>
<script src="./js/type.js" type="text/javascript"></script>
<!-- Ignore the rest of this... just a script to toggle the styles on and off -->
<script type="text/javascript">
var toggle = document.getElementById('toggle');
toggle.addEventListener('click', function(e) {
if (this.rel == 'on') {
var eles = document.querySelectorAll('*'),
spans = document.querySelectorAll('span');
spans[0].parentNode.textContent = spans[0].parentNode.textContent
for (i in eles) {
var ele = eles[i];
if (ele.innerHTML) ele.removeAttribute('style');
}
this.setAttribute('rel', 'off');
this.textContent = 'Turn on type.js'
}
else {
window.location.reload(false);
}
prevent(e);
}, false);
function prevent (e) {
if (e.preventDefault) e.preventDefault();
else event.returnValue = false;
}
</script>
</body>
</html>