-
Notifications
You must be signed in to change notification settings - Fork 843
/
Copy pathfont-variant-alternates.html
268 lines (242 loc) · 6.9 KB
/
font-variant-alternates.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Font feature example - alternates</title>
<style>
@font-face{
font-family: 'Plex Serif';
font-weight: normal;
font-style: normal;
font-stretch: normal;
src: url('fonts/plex/IBMPlexSerif-Regular.woff') format('woff'),
url('fonts/plex/IBMPlexSerif-Regular.woff2') format('woff2');
}
@font-face{
font-family: 'Dancing Script';
font-weight: normal;
font-style: normal;
font-stretch: normal;
src: url('fonts/dancing-script/dancing-script-regular.woff') format('woff'),
url('fonts/dancing-script/dancing-script-regular.woff2') format('woff2');
}
html {
box-sizing: border-box;
font-size: 100%;
}
*,
*::before,
*::after {
box-sizing: inherit;
}
body {
font: 1.2em "Plex Serif", "Times New Roman", serif;
margin: 20px;
padding: 0;
}
.script {
font-family: "Dancing Script";
}
.wrapper {
width: 100%;
display: grid;
grid-template-columns: 1fr;
grid-gap: 1rem;
}
@media screen and (min-width: 35rem) {
.wrapper {
grid-template-columns: 1fr 1fr;
}
}
@media screen and (min-width: 52rem) {
.wrapper {
grid-template-columns: 1fr 1fr;
}
}
textarea {
font-family: monospace;
display: block;
margin-bottom: 10px;
height: 160px;
background-color: #F4F7F8;
border: none;
border-left: 6px solid #558ABB;
color: #4D4E53;
padding: 1rem 0;
width: 100%;
}
textarea:nth-of-type(1) {
height: 280px;
}
textarea:nth-of-type(2) {
height: 100px;
}
.playable-buttons {
text-align: right;
width: 100%;
padding: 0.5rem 0;
font-size: 100%;
}
.section {
width: 100%;
border: 1px solid #4D4E53;
border-radius: 2px;
padding: 10px 14px 10px 10px;
margin-bottom: 10px;
}
.section input {
display: block;
margin: 5px;
}
.container * {
font-size: 4rem;
margin: 1.5rem 0;
}
</style>
<style class="editable1">
@font-feature-values "Plex Serif" {
@styleset { alt-a: 1; alt-g: 2; }
@stylistic { alternates: 1; }
}
@font-feature-values "Dancing Script" {
@stylistic { alternates: 1; }
}
.container1 * {
font-variant-alternates: styleset(alt-a);
}
.container1 .script {
font-variant-alternates: stylistic(alternates);
}
.inactive .container1 * {
font-variant-alternates: normal;
}
</style>
<style class="editable2">
.container2 * {
font-feature-settings: 'ss01';
}
.container2 .script {
font-feature-settings: 'salt';
}
.inactive .container2 * {
font-feature-settings: 'ss01' 0, 'salt' 0;
}
</style>
</head>
<body>
<div class="wrapper">
<div class="demo1">
<section class="section section1">
<div class="container container1">
<p><span class="script">My</span> Perfidious pangram</p>
</div>
</section>
<textarea class="playable-css1">
@font-feature-values "Plex Serif" {
@styleset { alt-a: 1; alt-g: 2; }
@stylistic { alternates: 1; }
}
@font-feature-values "Dancing Script" {
@stylistic { alternates: 1; }
}
.container1 * {
font-variant-alternates: styleset(alt-a);
}
.container1 .script {
font-variant-alternates: stylistic(alternates);
}
.inactive .container1 * {
font-variant-alternates: normal;
}
</textarea>
<textarea id="code1" class="playable-html1">
<div class="container container1">
<p><span class="script">My</span> Perfidious pangram</p>
</div>
</textarea>
<input type="checkbox" name="demo1_control" id="demo1_control" value="on" checked /> <label for="demo1_control">Alternates active</label>
</div>
<div class="demo2">
<section class="section section2">
<div class="container container2">
<p><span class="script">My</span> Perfidious pangram</p>
</div>
</section>
<textarea class="playable-css2">
.container2 * {
font-feature-settings: 'ss01';
}
.container2 .script {
font-feature-settings: 'salt';
}
.inactive .container2 * {
font-feature-settings: 'ss01' 0, 'salt' 0;
}
</textarea>
<textarea id="code2" class="playable-html2">
<div class="container container2">
<p><span class="script">My</span> Perfidious pangram</p>
</div>
</textarea>
<input type="checkbox" name="demo2_control" id="demo2_control" value="on" checked /> <label for="demo2_control">Alternates active</label>
</div>
</div>
<div class="playable-buttons">
<input id="reset" type="button" value="Reset">
</div>
</body>
<script>
var section1 = document.querySelector('.section1');
var editable1 = document.querySelector('.editable1');
var textareaHTML1 = document.querySelector('.playable-html1');
var textareaCSS1 = document.querySelector('.playable-css1');
var section2 = document.querySelector('.section2');
var editable2 = document.querySelector('.editable2');
var textareaHTML2 = document.querySelector('.playable-html2');
var textareaCSS2 = document.querySelector('.playable-css2');
var rangeinput = document.querySelector('.controls--slider');
var reset = document.getElementById('reset');
var htmlCode1 = textareaHTML1.value;
var cssCode1 = textareaCSS1.value;
var htmlCode2 = textareaHTML2.value;
var cssCode2 = textareaCSS2.value;
var demo1_active = document.getElementById('demo1_control');
var demo2_active = document.getElementById('demo2_control');
demo1_active.addEventListener('change', function () {
if (this.checked) {
this.parentNode.classList.remove('inactive');
} else {
this.parentNode.classList.add('inactive');
}
});
demo2_active.addEventListener('change', function () {
if (this.checked) {
this.parentNode.classList.remove('inactive');
} else {
this.parentNode.classList.add('inactive');
}
});
function fillCode() {
editable1.innerHTML = textareaCSS1.value;
section1.innerHTML = textareaHTML1.value;
editable2.innerHTML = textareaCSS2.value;
section2.innerHTML = textareaHTML2.value;
}
reset.addEventListener('click', function () {
textareaHTML1.value = htmlCode1;
textareaCSS1.value = cssCode1;
textareaHTML2.value = htmlCode2;
textareaCSS2.value = cssCode2;
demo1_active.checked = true;
demo1_active.parentNode.classList.remove('inactive');
demo2_active.checked = true;
demo2_active.parentNode.classList.remove('inactive');
fillCode();
});
textareaHTML1.addEventListener('input', fillCode);
textareaCSS1.addEventListener('input', fillCode);
textareaHTML2.addEventListener('input', fillCode);
textareaCSS2.addEventListener('input', fillCode);
window.addEventListener('load', fillCode);
</script>
</html>