forked from abrudz/APL386
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.py
More file actions
469 lines (443 loc) · 22 KB
/
Copy pathscript.py
File metadata and controls
469 lines (443 loc) · 22 KB
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
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
import fontforge
import os
import sys
from itertools import chain, combinations
import csv
import json
def powerset(iterable):
s = list(iterable)
return chain.from_iterable(combinations(s, r) for r in range(len(s)+1))
EXTENSIONS = [
'ttf',
'otf',
'woff',
'woff2',
'svg',
]
FEATURES = {
'ss01': 'Dotless zeros',
'ss02': 'Centered tilde in ⍱⍲⍫',
'cv01': 'Diaeresis and dot composition in ∵∴',
}
path = sys.argv[1]
commit = sys.argv[2]
apl387 = fontforge.open(f'{path}/APL387.ufo2')
apl387.version = commit
braille_dots = [apl387.createMappedChar(f'part_braille_dot_{i+1}') for i in range(8)]
for braille_index in range(0x100):
glyph = apl387.createChar(0x2800 + braille_index)
apl387.selection.select('space')
apl387.copy()
apl387.selection.select(glyph)
apl387.paste()
bits = [ch == '1' for ch in bin(braille_index)[2:].rjust(8, '0')][::-1]
if braille_index in [0x1b, 0xc0]:
print(bits)
for bit_idx, bit in enumerate(bits):
if bit:
apl387.selection.select(braille_dots[bit_idx])
apl387.copy()
apl387.selection.select(glyph)
apl387.pasteInto()
try:
os.mkdir(f'{path}/output')
except:
pass
features = [apl387.getLookupInfo(lookup)[2][0][0] for lookup in apl387.gsub_lookups]
with open(f'{path}/output/chars.html', 'w') as chars:
chars.write('''
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Characters - APL385 vs new APL387</title>
<style>
@font-face {font-family: 'APL385';src: url('APL385.ttf');}
@font-face {font-family: 'APL387';src: url('APL387.ttf');}
td{text-align:center;font-size:200}
td:first-child{font-family:APL385}
td:last-child{font-family:APL387}
span{white-space:pre}
</style>
</head>
<body onload="w=document.querySelector`span`.offsetWidth;document.querySelectorAll`span`.forEach(e=>e.style.opacity=0.2**(e.offsetWidth!=w))">
<table>
<tr><th>APL385 Unicode</th><th>new APL387 Unicode</th></tr>
''')
for gl in sorted((gl for gl in apl387.glyphs() if gl.unicode != -1), key=lambda gl: gl.unicode):
chars.write(f'<tr><td><span>&#{gl.unicode};</span></td><td><span>&#{gl.unicode};</span></td></tr>\n')
chars.write('''
</table>
</body>
</html>
''')
def compare_page(font, old, new, propo = False, name = 'compare'):
with open(f'{path}/output/{name}.html', 'w', encoding='utf-8') as compare:
compare.write(f'''
<html lang="en">
<head>
<meta charset="utf-8" />
<title>{new} Comparison</title>
<style>
@font-face {'{'}font-family: '{new}';src: url('{new}.ttf');{'}'}
@font-face {'{'}font-family: '{old}';src: url('{old}.ttf');{'}'}
#{old}{'{'}font-family:{old}!important{'}'}
#{new}{'{'}font-family:{new}!important{'}'}
''' + '''
* {
font-weight: unset;
font-feature-settings: inherit;
}
body {
font-size: 200%;
line-height: 1.2;
margin:0;
}
blockquote {
-webkit-hyphens: auto;
-ms-hyphens: auto;
hyphens: auto;
font-size: 125%;
word-break: break-all;
}
pre{font-family:inherit}
textarea {
width: 100%;
resize: vertical;
min-height: 4em;
font-size: inherit;
font-family: inherit;
font-size:inherit;
}
table{font-size:inherit}
section{width:49vw;overflow:hidden;display:inline-block;top:0;vertical-align:top}
</style>
</head>
<body>
''')
for feature in features:
compare.write(f'<div><input id="{feature}" type="checkbox" name="{feature}" value="{feature}"><label for="{feature}">{f"{feature} ({FEATURES[feature]})" if feature in FEATURES else feature}</label></div>')
compare.write('<br><a href="./chars">compare characters individually</a>')
same = '''
<textarea id="ta385" placeholder="Try it yourself ― type here!" spellcheck="false" oninput"ta387.value=this.value"></textarea>
<p>Supports every special character used by any APL implementation:</p>
<table>
<tbody><tr><th>Class</th>
<th>Glyphs
</th></tr>
<tr><td>alphas</td><td>⍺⍶</td></tr>
<tr><td>arrows-down</td><td>↓⍗⍖</td></tr>
<tr><td>arrows-left</td><td>←⍇⍅</td></tr>
<tr><td>arrows-right</td><td>→⍈⍆➥</td></tr>
<tr><td>arrows-up</td><td>↑⍐⍏</td></tr>
<tr><td>asterisks</td><td>*⍣⍟⋆</td></tr>
<tr><td>brackets</td><td>[]⌈⌊⌷</td></tr>
<tr><td>circles</td><td>○⍥⍟⌽⍉⊖⍜⊙⌾∅</td></tr>
<tr><td>colons</td><td>:⍠÷⌹</td></tr>
<tr><td>commas</td><td>,⍪;⍮</td></tr>
<tr><td>dashes</td><td>-+±÷⌹⌿⍀⍪⍏⍖⊢⊣</td></tr>
<tr><td>dels</td><td>∇⍒⍫⍢</td></tr>
<tr><td>deltas</td><td>∆⍙⍋⍍</td></tr>
<tr><td>diamonds</td><td>⋄⌺⍚</td></tr>
<tr><td>diereses</td><td>¨⍨⍥⍤⍣⍢⍡⍩ᑈᐵ</td></tr>
<tr><td>dots</td><td>.:,;?!‼⍰</td></tr>
<tr><td>epsilons</td><td>∊⍷</td></tr>
<tr><td>equals</td><td>=≠⌸⍯</td></tr>
<tr><td>iotas</td><td>⍳⍸</td></tr>
<tr><td>jots</td><td>∘⍤⍛⍝⍎⍕¤⌾⟃⟄</td></tr>
<tr><td>letters</td><td>⍺⍶∆⍙∂∊⍷⍳⍸λπ⍴ϼχ∫</td></tr>
<tr><td>omegas</td><td>⍵⍹</td></tr>
<tr><td>quads</td><td>⎕⌸⌹⌺⌻⌼⍁⍂⍃⍄⍇⍈⍌⍍⍐⍓⍯⍰</td></tr>
<tr><td>shoes-down</td><td>∪⍦</td></tr>
<tr><td>shoes-left</td><td>⊂⊆⍧⟃</td></tr>
<tr><td>shoes-right</td><td>⊃⊇⟄</td></tr>
<tr><td>shoes-up</td><td>∩⋔</td></tr>
<tr><td>slashes</td><td>/⌿⍁%</td></tr>
<tr><td>slashes-back</td><td>\⍀⍉⍂</td></tr>
<tr><td>stiles</td><td>|⌽⍒⍋∥⍭¦⍦⍧$</td></tr>
<tr><td>tacks-down</td><td>⌶⊤⍕⍑⍡</td></tr>
<tr><td>tacks-up</td><td>⌶⊥⍎⍊</td></tr>
<tr><td>tildes</td><td>~⍬⍭⍱⍲</td></tr>
<tr><td>underscores</td><td>_⍙⍷⍛⍸⊆⊇⍊⍜⍶⍹⍮⍚⍘</td></tr>
<tr><td>wedges-down</td><td>∨⍱⍌</td></tr>
<tr><td>wedges-left</td><td><≤⍃ᑈ</td></tr>
<tr><td>wedges-right</td><td>>≥⍄⍩ᐵ</td></tr>
<tr><td>wedges-up</td><td>∧⍲⍓</td></tr></tbody></table>
<p>Vertical alignment: +-×÷*⊂∘○~←⌶⊥⊢<=</p>
<p>And many additional mathematical, typographical, pictogram symbols:</p>
<blockquote>
¦‖¬°∓µ·∵¼½¾↔↕∉≉≣⊖⊕⊖⊗⊘⊝⊛⊻⊼⊽⋔⌈⌉⌊⌋<br>
`´¡¿‼‽¢£¤¥ © ® ºª«»‘’‚‛“”„‟§¶<br>
♔♕♖♗♘♙♚♛♜♝♞♟♠♡♢♣♤♥♦♧♀♂
</blockquote>''' + ('''
<p>Single and double line drawing characters, and blocks and shades:</p>
<blockquote style="line-height: 1.15;">┌─┬┐ ╔═╦╗ ▁▂▃▄▅▆▇█<br>
│ ││ ║ ║║ █▉▊▋▌▍▎▏<br>
├─┼┤ ╠═╬╣ ▌▀▄▐<br>
└─┴┘ ╚═╩╝ ░▒▓</blockquote>''' if not propo else '') + '''
<p>Includes both uppercase and lowercase underscored alphabets, plus superscript and subscript digits:</p>
<blockquote>
ⒶⒷⒸⒹⒺⒻⒼⒽⒾⒿⓀⓁⓂⓃⓄⓅⓆⓇⓈⓉⓊⓋⓌⓍⓎⓏ<br>
ⓐⓑⓒⓓⓔⓕⓖⓗⓘⓙⓚⓛⓜⓝⓞⓟⓠⓡⓢⓣⓤⓥⓦⓧⓨⓩ<br>
⁰¹²³⁴⁵⁶⁷⁸⁹ ₀₁₂₃₄₅₆₇₈₉</blockquote>
<p>Extensive set of accented Latin letters:</p>
<blockquote style="word-break: break-all;">ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĆćĈĉĊċĖėĠġĢģĤĥĨĩİıĴĵĶķĹĺĻļŃńŅņŔŕŖŗŚśŜŝŨũŴŵŶŷŸŹźŻżƒǴǵǸǹǼǽǾǿȨȩȮȯ</blockquote>
<p>Full support for Greek:</p>
<blockquote>Ά·ΈΉΊΌΎΏΐΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩΪΫάέήίΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύώϕϖϜϝϲϳϴϵ϶ϷϸϹϼϽϾϿ</blockquote>
<p>And Cyrillic:</p>
<blockquote>ЀЁЂЃЄЅІЇЈЌЍЎЏАБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюяѐёѓєѕіїјў</blockquote>
<p>Sample APL code:</p>
<blockquote style="line-height: 1;"><pre style="font-family: inherit;">''' + ('''
w←⊃(⊃0⍴⍵){ ⍝┌┌─2─┐ monadic; use ↓
(e a)←|⍺ ⍝├ 0 0 1 1 1 dyadic; use /
T←⌽⍣(0>⊃⌽⍺) ⍝└──→⍺⍺←─────┐
Pad←⍵⍵⍉(T⊣)⍪⍵⍪(T⊢) ⍝ ┌⍺┐ ⌺ │
need←(1+e),1↓⍴⍵ ⍝ ┌─────⍵⍵──┐┘
a=0:(1↓need⍴0↑⍵)Pad(1↓need⍴0↑⊢⍵) ⍝ 0 0│1 2 3 4 5│0 0 Zero
a=1:(1↓need⍴1↑⍵)Pad(1↓need⍴1↑⊖⍵) ⍝ 1 1│1 2 3 4 5│5 5 Replicate
a=2:(⊖¯1↓need⍴⊢⍵)Pad(¯1↓need⍴⊖⍵) ⍝ 2 1│1 2 3 4 5│5 4 Reverse
a=3:(⊖⊢1↓need⍴⊢⍵)Pad(⊢1↓need⍴⊖⍵) ⍝ 3 2│1 2 3 4 5│4 3 Mirror
a=4:(⊖¯1↓need⍴⊖⍵)Pad(¯1↓need⍴⊢⍵) ⍝ 4 5│1 2 3 4 5│1 2 Wrap
}(¯1⌽⍳≢⍴⍵)/(⌽extra,¨⍺⊣0),⊂⍵ ⍝ └────⍵────┘''' if not propo else '''
w←⊃(⊃0⍴⍵){
(e a)←|⍺
T←⌽⍣(0>⊃⌽⍺)
Pad←⍵⍵⍉(T⊣)⍪⍵⍪(T⊢)
need←(1+e),1↓⍴⍵
a=0:(1↓need⍴0↑⍵)Pad(1↓need⍴0↑⊢⍵)
a=1:(1↓need⍴1↑⍵)Pad(1↓need⍴1↑⊖⍵)
a=2:(⊖¯1↓need⍴⊢⍵)Pad(¯1↓need⍴⊖⍵)
a=3:(⊖⊢1↓need⍴⊢⍵)Pad(⊢1↓need⍴⊖⍵)
a=4:(⊖¯1↓need⍴⊖⍵)Pad(¯1↓need⍴⊢⍵)
}(¯1⌽⍳≢⍴⍵)/(⌽extra,¨⍺⊣0),⊂⍵''') + '''</pre></blockquote>
<p>Sample text:</p>
<blockquote>APL (named after the book A Programming Language) is a programming language developed in the 1960s by Kenneth E. Iverson. Its central datatype is the multidimensional array. It uses a large range of special graphic symbols to represent most functions and operators, leading to very concise code. It has been an important influence on the development of concept modeling, spreadsheets, functional programming, and computer math packages. It has also inspired several other programming languages.</blockquote>
<p>All supported characters:</p>
<pre>
'''
for idx, gl in enumerate(sorted((gl for gl in font.glyphs() if gl.unicode != -1), key=lambda gl: gl.unicode)):
if idx != 0 and idx % 16 == 0: same += '\n'
same += f'&#{gl.unicode};'
same += '</pre>'
compare.write(f'''
<div>
<section id='{old}'><h2>{old} Unicode</h2>
{same}
</section>
<section id='{new}'><h2>New {new} Unicode</h2>
{same}
</section>
</div>
<script src="features.js"></script>
</body>
</html>
''')
def index_page(old, new, propo = False, name = 'index', compare_name = 'compare'):
with open(f'{path}/output/{name}.html', 'w', encoding='utf-8') as index:
index.write(f'''
<html lang="en">
<head>
<meta charset="utf-8" />
<title>{new} - A New {old}</title>
<link rel="shortcut icon" href="favicon.ico"/>
<link rel="stylesheet" href="index.css">
</head>
<body>
<div class="c">
<input id="{new}" class="x" type="radio" name="f" value="{new}" checked=""><label class="x" for="APL387">{new}.ttf</label>
<input id="{old}" class="x" type="radio" name="f" value="{old}" ><label class="x" for="APL387">{old}.ttf</label>
<br>
''')
for feature in features:
index.write(f'<div><input id="{feature}" type="checkbox" name="{feature}" value="{feature}"><label for="{feature}">{f"{feature} ({FEATURES[feature]})" if feature in FEATURES else feature}</label></div>')
index.write(f'''
</div>
<h1>{new} Unicode<sup> <a href="{new}.ttf">download</a> <a href="" id="wb">download with baked features</a></sup> <span><sup><a href="./{compare_name}">side by side with {old}</a></sup> <sup><a href="https://github.com/dyalog/APL387">source</a></sup></span></h1>
<p>A redrawn and extended version of Adrian Smith's classic <a href="https://apl385.com/fonts/index.htm">{old}</a> font with clean rounded look.</p>
<p><a href=".">APL387 (monospace)</a> <a href="./335">APL335 (proportional)</a></p>
<blockquote>
<textarea autofocus placeholder="Try it yourself ― type here!" spellcheck="false"></textarea>
</blockquote>
<p>Supports every special character used by any APL implementation:</p>
<table>
<tbody><tr><th>Class</th>
<th>Glyphs
</th></tr>
<tr><td>alphas</td><td>⍺⍶</td></tr>
<tr><td>arrows-down</td><td>↓⍗⍖</td></tr>
<tr><td>arrows-left</td><td>←⍇⍅</td></tr>
<tr><td>arrows-right</td><td>→⍈⍆➥</td></tr>
<tr><td>arrows-up</td><td>↑⍐⍏</td></tr>
<tr><td>asterisks</td><td>*⍣⍟⋆</td></tr>
<tr><td>brackets</td><td>[]⌈⌊⌷</td></tr>
<tr><td>circles</td><td>○⍥⍟⌽⍉⊖⍜⊙⌾∅</td></tr>
<tr><td>colons</td><td>:⍠÷⌹</td></tr>
<tr><td>commas</td><td>,⍪;⍮</td></tr>
<tr><td>dashes</td><td>-+±÷⌹⌿⍀⍪⍏⍖⊢⊣</td></tr>
<tr><td>dels</td><td>∇⍒⍫⍢</td></tr>
<tr><td>deltas</td><td>∆⍙⍋⍍</td></tr>
<tr><td>diamonds</td><td>⋄⌺⍚</td></tr>
<tr><td>diereses</td><td>¨⍨⍥⍤⍣⍢⍡⍩</td></tr>
<tr><td>dots</td><td>.:,;?!⍰</td></tr>
<tr><td>epsilons</td><td>∊⍷</td></tr>
<tr><td>equals</td><td>=≠⌸⍯</td></tr>
<tr><td>iotas</td><td>⍳⍸</td></tr>
<tr><td>jots</td><td>∘⍤⍛⍝⍎⍕¤⌾⟃⟄</td></tr>
<tr><td>letters</td><td>⍺⍶∆⍙∂∊⍷⍳⍸λπ⍴ϼχ∫</td></tr>
<tr><td>omegas</td><td>⍵⍹</td></tr>
<tr><td>quads</td><td>⎕⌸⌹⌺⌻⌼⍁⍂⍃⍄⍇⍈⍌⍍⍐⍓⍯⍰</td></tr>
<tr><td>shoes-down</td><td>∪⍦</td></tr>
<tr><td>shoes-left</td><td>⊂⊆⍧⟃</td></tr>
<tr><td>shoes-right</td><td>⊃⊇⟄</td></tr>
<tr><td>shoes-up</td><td>∩⋔⍝</td></tr>
<tr><td>slashes</td><td>/⌿⍁%</td></tr>
<tr><td>slashes-back</td><td>\⍀⍉⍂</td></tr>
<tr><td>stiles</td><td>|⌽⍒⍋∥⍭⍦⍧$</td></tr>
<tr><td>tacks-down</td><td>⌶⊤⍕⍑⍡</td></tr>
<tr><td>tacks-up</td><td>⌶⊥⍎⍊</td></tr>
<tr><td>tildes</td><td>~⍬⍭⍱⍲</td></tr>
<tr><td>underscores</td><td>_⍙⍷⍛⍸⊆⊇⍊⍜⍶⍹⍮⍚⍘</td></tr>
<tr><td>wedges-down</td><td>∨⍱⍌</td></tr>
<tr><td>wedges-left</td><td><≤⍃ᑈ</td></tr>
<tr><td>wedges-right</td><td>>≥⍄⍩ᐵ</td></tr>
<tr><td>wedges-up</td><td>∧⍲⍓</td></tr></tbody></table>
<p>And many additional mathematical, typographical, pictogram symbols:</p>
<blockquote>
¦‖¬°∓µ·∵¼½¾↔↕∉≉≣⊖⊕⊖⊗⊘⊝⊛⊻⊼⊽⋔⌈⌉⌊⌋<br>
`´¡¿‼‽¢£¤¥ © ® ºª«»‘’‚‛“”„‟§¶<br>
♔♕♖♗♘♙♚♛♜♝♞♟♠♡♢♣♤♥♦♧♀♂
</blockquote>''' + ('''
<p>Single and double line drawing characters, and blocks and shades:</p>
<blockquote style="line-height: 1.15;">┌─┬┐ ╔═╦╗ ▁▂▃▄▅▆▇█<br>
│ ││ ║ ║║ █▉▊▋▌▍▎▏<br>
├─┼┤ ╠═╬╣ ▌▀▄▐<br>
└─┴┘ ╚═╩╝ ░▒▓</blockquote>''' if not propo else '') + '''
<p>Includes both uppercase and lowercase underscored and double-struck alphabets, plus superscript and subscript digits:</p>
<blockquote>
ⒶⒷⒸⒹⒺⒻⒼⒽⒾⒿⓀⓁⓂⓃⓄⓅⓆⓇⓈⓉⓊⓋⓌⓍⓎⓏ<br>
ⓐⓑⓒⓓⓔⓕⓖⓗⓘⓙⓚⓛⓜⓝⓞⓟⓠⓡⓢⓣⓤⓥⓦⓧⓨⓩ<br>
𝔸𝔹ℂ𝔻𝔼𝔽𝔾ℍ𝕀𝕁𝕂𝕃𝕄ℕ𝕆ℙℚℝ𝕊𝕋𝕌𝕍𝕎𝕏𝕐ℤ<br>
𝕒𝕓𝕔𝕕𝕖𝕗𝕘𝕙𝕚𝕛𝕜𝕝𝕞𝕟𝕠𝕡𝕢𝕣𝕤𝕥𝕦𝕧𝕨𝕩𝕪𝕫<br>
𝟘𝟙𝟚𝟛𝟜𝟝𝟞𝟟𝟠𝟡 ⁰¹²³⁴⁵⁶⁷⁸⁹ ₀₁₂₃₄₅₆₇₈₉</blockquote>
<p>Extensive set of accented Latin letters:</p>
<blockquote style="word-break: break-all;">ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĆćĈĉĊċĖėĠġĢģĤĥĨĩİıĴĵĶķĹĺĻļŃńŅņŔŕŖŗŚśŜŝŨũŴŵŶŷŸŹźŻżƒǴǵǸǹǼǽǾǿȨȩȮȯ</blockquote>
<p>Full support for Greek:</p>
<blockquote>Ά·ΈΉΊΌΎΏΐΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩΪΫάέήίΰαβγδεζηθικλμνξοπρςστυφχψωϊϋόύώϕϖϜϝϲϳϴϵ϶ϷϸϹϼϽϾϿ</blockquote>
<p>And Cyrillic:</p>
<blockquote>ЀЁЂЃЄЅІЇЈЌЍЎЏАБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюяѐёѓєѕіїјў</blockquote>
<p>Sample APL code:</p>
<blockquote style="line-height: 1;"><pre style="font-family: inherit;">''' + ('''
w←⊃(⊃0⍴⍵){ ⍝┌┌─2─┐ monadic; use ↓
(e a)←|⍺ ⍝├ 0 0 1 1 1 dyadic; use /
T←⌽⍣(0>⊃⌽⍺) ⍝└──→⍺⍺←─────┐
Pad←⍵⍵⍉(T⊣)⍪⍵⍪(T⊢) ⍝ ┌⍺┐ ⌺ │
need←(1+e),1↓⍴⍵ ⍝ ┌─────⍵⍵──┐┘
a=0:(1↓need⍴0↑⍵)Pad(1↓need⍴0↑⊢⍵) ⍝ 0 0│1 2 3 4 5│0 0 Zero
a=1:(1↓need⍴1↑⍵)Pad(1↓need⍴1↑⊖⍵) ⍝ 1 1│1 2 3 4 5│5 5 Replicate
a=2:(⊖¯1↓need⍴⊢⍵)Pad(¯1↓need⍴⊖⍵) ⍝ 2 1│1 2 3 4 5│5 4 Reverse
a=3:(⊖⊢1↓need⍴⊢⍵)Pad(⊢1↓need⍴⊖⍵) ⍝ 3 2│1 2 3 4 5│4 3 Mirror
a=4:(⊖¯1↓need⍴⊖⍵)Pad(¯1↓need⍴⊢⍵) ⍝ 4 5│1 2 3 4 5│1 2 Wrap
}(¯1⌽⍳≢⍴⍵)/(⌽extra,¨⍺⊣0),⊂⍵ ⍝ └────⍵────┘''' if not propo else '''
w←⊃(⊃0⍴⍵){
(e a)←|⍺
T←⌽⍣(0>⊃⌽⍺)
Pad←⍵⍵⍉(T⊣)⍪⍵⍪(T⊢)
need←(1+e),1↓⍴⍵
a=0:(1↓need⍴0↑⍵)Pad(1↓need⍴0↑⊢⍵)
a=1:(1↓need⍴1↑⍵)Pad(1↓need⍴1↑⊖⍵)
a=2:(⊖¯1↓need⍴⊢⍵)Pad(¯1↓need⍴⊖⍵)
a=3:(⊖⊢1↓need⍴⊢⍵)Pad(⊢1↓need⍴⊖⍵)
a=4:(⊖¯1↓need⍴⊖⍵)Pad(¯1↓need⍴⊢⍵)
}(¯1⌽⍳≢⍴⍵)/(⌽extra,¨⍺⊣0),⊂⍵''') + f'''</pre></blockquote>
<p>Sample text:</p>
<blockquote>APL (named after the book A Programming Language) is a programming language developed in the 1960s by Kenneth E. Iverson. Its central datatype is the multidimensional array. It uses a large range of special graphic symbols to represent most functions and operators, leading to very concise code. It has been an important influence on the development of concept modeling, spreadsheets, functional programming, and computer math packages. It has also inspired several other programming languages.</blockquote>
</body>
<script src="features.js" data-base="{new}"></script>
</html>
''')
for glyph in apl387.glyphs(): glyph.unlinkRef()
def bake_feature(lookup: str):
subtable = apl387.getLookupSubtables(lookup)[0]
to_swap = []
for glyph in apl387.glyphs():
lookups = glyph.getPosSub(subtable)
if len(lookups) == 0: continue
elif len(lookups) == 1:
to_swap.append((glyph, apl387.createMappedChar(lookups[0][2])))
else:
raise RuntimeError(f'Glyph {glyph.glyphname} has more than one lookup, I don\'t know what to do.')
for a, b in to_swap:
swap_glyphs(a, b)
temp = apl387.createChar(-1, 'swapTemp')
def swap_glyphs(a, b):
apl387.selection.select(a)
apl387.copy()
apl387.selection.select(temp)
apl387.paste()
apl387.selection.select(b)
apl387.copy()
apl387.selection.select(a)
apl387.paste()
apl387.selection.select(temp)
apl387.copy()
apl387.selection.select(b)
apl387.paste()
def export_all(name, font):
for subset in powerset(font.gsub_lookups):
baked_features = [font.getLookupInfo(lookup)[2][0][0] for lookup in subset]
font.familyname = name
font.fontname = f'{name}{"".join(baked_features)}' if len(subset) else f'{name}'
font.fullname = f'{name} Unicode {" ".join(baked_features)}' if len(subset) else f'{name} Unicode'
font.sfnt_names = (
('English (US)', 'Copyright', 'Public Domain'),
('English (US)', 'Designer', 'Adám Brudzewsky'),
('English (US)', 'Family', name),
('English (US)', 'SubFamily', 'Book'),
('English (US)', 'Preferred Family', f'{name} Unicode {" ".join(baked_features)}' if len(subset) else f'{name} Unicode'),
('English (US)', 'Preferred Styles', 'Regular'),
)
file_name = f'{name}-{"-".join(baked_features)}' if len(subset) else name
for lookup in subset:
bake_feature(lookup)
for ext in EXTENSIONS:
font.generate(f'{path}/output/{file_name}.{ext}')
# undo swaps
for lookup in subset:
bake_feature(lookup)
export_all('APL387', apl387)
compare_page(apl387, 'APL385', 'APL387')
index_page('APL385', 'APL387')
apl335 = apl387 # no need to clone, original font isn't needed anymore
for glyph in apl335.glyphs():
if (glyph.glyphname.startswith('part_') # ignore parts
or glyph.glyphname.endswith('.bottom') # ignore math components
or glyph.glyphname.endswith('.top')
or glyph.glyphname.endswith('.left')
or glyph.glyphname.endswith('.right')
or glyph.glyphname.endswith('.extender')
): continue
glyph.left_side_bearing = 50
glyph.right_side_bearing = 50
apl335.createChar(0x20).left_side_bearing = 200 # space should be wider
apl335.addLookup('kern', 'gpos_pair', (), (('kern', (('DFLT', ('dflt',)), ('brai', ('dflt',)), ('cans', ('dflt',)), ('cyrl', ('dflt',)), ('grek', ('dflt',)), ('latn', ('dflt',)), ('math', ('dflt',)), ('nko ', ('dflt',)), ('tfng', ('dflt',)))),))
apl335.addLookupSubtable('kern', 'kern-0')
with open(f'{path}/kerning.tsv') as kerning:
reader = csv.reader(kerning, delimiter='\t')
for line in reader:
first = apl335.createChar(ord(line[0]))
second = apl335.createChar(ord(line[1]))
kern = int(line[2])
first.addPosSub('kern-0', second.glyphname, kern)
with open(f'{path}/math.json', 'rb') as math:
data = json.load(math)
for k, v in data['properties'].items():
# font.math doesn't support [] assignment sadly
exec(f'apl335.math.{k} = {int(v)}', { 'apl335': apl335 })
for k, v in data['vconstruct'].items():
glyph = apl335.createMappedChar(k)
glyph.verticalComponents = tuple(tuple(part) for part in v)
for k, v in data['hconstruct'].items():
glyph = apl335.createMappedChar(k)
glyph.horizontalComponents = tuple(tuple(part) for part in v)
export_all('APL335', apl335)
compare_page(apl335, 'APL333', 'APL335', propo = True, name = 'compare335')
index_page('APL333', 'APL335', propo = True, name = '335', compare_name = 'compare335')