-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvariant-coverage.html
More file actions
533 lines (465 loc) · 25.8 KB
/
Copy pathvariant-coverage.html
File metadata and controls
533 lines (465 loc) · 25.8 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
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
<!DOCTYPE html>
<html lang="zh-Hant">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SarasaMonoTCEmoji — 分類覆蓋率</title>
<style>
/* ── Load from build output (output/ is gitignored; local dev only) ── */
@font-face {
font-family: 'OutColor';
src: url('output/fonts/SarasaMonoTCEmoji-Regular.ttf') format('truetype');
font-weight: normal; font-style: normal;
}
@font-face {
font-family: 'OutLite';
src: url('output/fonts-lite/SarasaMonoTCEmojiLite-Regular.ttf') format('truetype');
font-weight: normal; font-style: normal;
}
@font-face {
font-family: 'OutCOLRv1';
src: url('output/fonts-colrv1/SarasaMonoTCEmojiCOLRv1-Regular.ttf') format('truetype');
font-weight: normal; font-style: normal;
}
@font-face {
font-family: 'OutNerd';
src: url('output/fonts-nerd-lite/SarasaMonoTCEmojiLiteNerd-Regular.ttf') format('truetype');
font-weight: normal; font-style: normal;
}
:root {
--color-font: 'OutColor', monospace;
--lite-font: 'OutLite', monospace;
--colrv1-font: 'OutCOLRv1', monospace;
--nerd-font: 'OutNerd', monospace;
}
body { font-family: sans-serif; margin: 40px; background: #1e1e2e; color: #cdd6f4; }
h1 { color: #cba6f7; }
h2 { color: #cba6f7; margin-top: 2em; border-bottom: 1px solid #313244; padding-bottom: 0.3em; }
/* ── hint box ─────────────────────────────── */
.hint {
background: #313244; border-radius: 8px; padding: 12px 16px;
font-size: 13px; color: #9399b2; margin: 1em 0; line-height: 1.8;
}
.hint code { background: #181825; padding: 1px 6px; border-radius: 4px; color: #a6e3a1; font-family: monospace; }
.hint .warn { color: #f9e2af; }
/* ── stats table ──────────────────────────── */
.stats-wrap { overflow-x: auto; margin: 1em 0; }
table.stats { border-collapse: collapse; width: 100%; min-width: 680px; font-size: 13px; }
table.stats th {
background: #313244; color: #cba6f7;
padding: 7px 12px; text-align: left; white-space: nowrap;
}
table.stats td { padding: 6px 12px; border-bottom: 1px solid #252530; }
table.stats tr:hover td { background: #252530; }
.n-all { color: #a6e3a1; font-family: monospace; }
.n-colrv1 { color: #fab387; font-family: monospace; }
.n-nerd { color: #94e2d5; font-family: monospace; }
.n-dim { color: #45475a; font-family: monospace; }
.tfoot td { font-weight: bold; background: #252530 !important; border-top: 2px solid #45475a; }
/* ── ctrl bar ─────────────────────────────── */
.ctrl-bar { margin: 1em 0 0.5em; display: flex; gap: 8px; flex-wrap: wrap; }
.ctrl {
background: #313244; border: 1px solid #45475a; color: #cdd6f4;
padding: 4px 14px; border-radius: 6px; font-size: 13px; cursor: pointer;
}
.ctrl:hover { background: #45475a; }
/* ── category details ─────────────────────── */
details { margin: 0.6em 0; }
details > summary {
cursor: pointer; padding: 9px 14px; background: #313244;
border-radius: 8px; font-weight: bold; color: #cdd6f4;
user-select: none; list-style: none;
}
details > summary::before { content: '▶ '; font-size: 11px; color: #6c7086; }
details[open] > summary::before { content: '▼ '; }
details > summary::-webkit-details-marker { display: none; }
.cat-meta { margin-left: 10px; font-size: 12px; color: #9399b2; font-weight: normal; }
.cat-meta .n-all { color: #a6e3a1; }
.cat-meta .n-colrv1 { color: #fab387; }
/* ── 4-col variant grid ───────────────────── */
.vgrid {
display: grid; grid-template-columns: repeat(4, 1fr);
gap: 10px; padding: 10px 0 4px;
}
@media (max-width: 900px) { .vgrid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .vgrid { grid-template-columns: 1fr; } }
.vcol { background: #181825; border-radius: 8px; padding: 10px 14px; }
.vcol-hd {
font-size: 11px; font-family: monospace; margin-bottom: 7px;
padding-bottom: 5px; border-bottom: 1px solid #313244;
}
.badge-color { color: #fab387; }
.badge-lite { color: #89dceb; }
.badge-colrv1 { color: #cba6f7; }
.badge-nerd { color: #94e2d5; }
.emoji-block { font-size: 20px; line-height: 2; word-break: break-word; overflow-wrap: break-word; white-space: normal; }
.f-color { font-family: var(--color-font); }
.f-lite { font-family: var(--lite-font); }
.f-colrv1 { font-family: var(--colrv1-font); }
.f-nerd { font-family: var(--nerd-font); }
.colrv1-sub { margin-top: 8px; padding-top: 7px; border-top: 1px solid #313244; }
.colrv1-sub-label { font-size: 11px; color: #fab387; margin-bottom: 3px; }
/* ── Nerd PUA 2-col grid ──────────────────── */
.ngrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 10px 0 4px; min-width: 0; }
@media (max-width: 600px) { .ngrid { grid-template-columns: 1fr; } }
.ncol { background: #181825; border-radius: 8px; padding: 10px 14px; min-width: 0; }
.ncol-hd { font-size: 12px; font-family: monospace; margin-bottom: 7px; }
.range-info { font-size: 11px; color: #6c7086; font-family: monospace; margin-top: 4px; }
/* ── font status table ──────────────────────── */
table.fstatus { border-collapse: collapse; font-size: 13px; width: 100%; }
table.fstatus th { background: #252530; color: #9399b2; padding: 5px 10px; text-align: left; font-weight: normal; }
table.fstatus td { padding: 5px 10px; border-bottom: 1px solid #252530; font-family: monospace; }
.fs-ok { color: #a6e3a1; }
.fs-err { color: #f38ba8; }
.fs-loading { color: #9399b2; }
</style>
</head>
<body>
<h1>SarasaMonoTCEmoji — Emoji 分類覆蓋率</h1>
<div class="hint">
<b>字體直接從 <code>output/</code> 載入(免安裝,即時反映建構結果)。</b><br>
<span class="warn">⚠ 此頁 emoji 為代表性樣本,非完整清單。
實際字體包含 Noto 全量 emoji(Color / Lite / Nerd Lite ~3,700+;COLRv1 向量彩色 540 個單碼字符,其餘單色備援)。<br>
若字體欄位顯示方塊或系統字形,請先執行 <code>uv run python build.py</code> 產出對應變體。</span>
</div>
<table class="fstatus" id="font-status-table">
<thead><tr><th>變體</th><th>字體檔案</th><th>狀態</th></tr></thead>
<tbody id="font-status-body"></tbody>
</table>
<h2>統計摘要</h2>
<div class="stats-wrap">
<table class="stats">
<thead>
<tr>
<th>分類</th>
<th>此頁收錄</th>
<th>Color(位圖彩色)</th>
<th>Lite(單色)</th>
<th>COLRv1 向量彩色</th>
<th>COLRv1 單色備援</th>
<th>Nerd Lite(+ PUA)</th>
</tr>
</thead>
<tbody id="stats-body">
<tr><td colspan="7" style="color:#6c7086;text-align:center">載入中…</td></tr>
</tbody>
</table>
</div>
<h2>Emoji 分類</h2>
<div class="ctrl-bar">
<button class="ctrl" onclick="setAll(true,'emoji')">全部展開</button>
<button class="ctrl" onclick="setAll(false,'emoji')">全部收合</button>
</div>
<div id="cat-container"></div>
<h2>Nerd Fonts PUA 圖示 <span style="font-size:14px;font-weight:normal;color:#9399b2">— Nerd Lite 專屬</span></h2>
<div class="hint" style="margin-bottom:0.5em">
左欄:<code>SarasaMonoTCEmojiLiteNerd</code>(應顯示圖示);右欄:<code>SarasaMonoTCEmojiLite</code>(□ = 正常缺字)。
</div>
<div class="ctrl-bar">
<button class="ctrl" onclick="setAll(true,'nerd')">全部展開</button>
<button class="ctrl" onclick="setAll(false,'nerd')">全部收合</button>
</div>
<div id="nerd-container"></div>
<!-- ================================================================
DATA + RENDERING (all DOM methods — no untrusted innerHTML)
================================================================ -->
<script>
'use strict';
// ── Emoji category data ───────────────────────────────────────────
const CATEGORIES = [
{ id: 'smileys', icon: '😀', name: 'Smileys & Emotion',
chars: '😀😃😄😁😆😅🤣😂🙂🙃🫠😉😊😇🥰😍🤩😘😗😚😙🥲😋😛😜🤪😝🤑🤗🤭🫢🫣🤫🤔🫡🤐🤨😐😑😶🫥😏😒🙄😬🤥🫨😌😔😪🤤😴😷🤒🤕🤢🤮🤧🥵🥶🥴😵🤯🤠🥳🥸😎🤓🧐😕🫤😟🙁☹😮😯😲😳🥺😦😧😨😰😥😢😭😱😖😣😞😓😩😫🥱😤😡😠🤬😈👿💀☠💩🤡👹👺👻👽👾🤖' },
{ id: 'people', icon: '👋', name: 'People & Body',
chars: '👋🤚🖐✋🖖🫱🫲🫳🫴🫷🫸👌🤌🤏✌🤞🫰🤟🤘🤙👈👉👆🖕👇☝🫵👍👎✊👊🤛🤜👏🙌🫶👐🤲🤝🙏💪🦵🦶👂🦻👃👁👄💋🧠🦷🦴💅🤳👤👥🫂' },
{ id: 'animals', icon: '🐶', name: 'Animals & Nature',
chars: '🐶🐱🐭🐹🐰🦊🐻🐼🐨🐯🦁🐮🐷🐸🐵🙈🙉🙊🐔🐧🐦🐤🦆🦅🦉🦇🐺🐗🐴🦄🐝🐛🦋🐌🐞🐜🦟🦗🦂🐢🐍🦎🐙🦑🦐🦞🦀🐡🐠🐟🐬🐳🦈🦭🦦🦥🐊🐆🐅🦓🐘🦛🦏🐪🐫🦒🦘🐃🐄🐎🐖🐏🐑🦙🐐🦌🐕🐩🐈🐓🦃🦚🦜🦢🦩🕊🐇🦝🦔🌲🌳🌴🌵🌾💐🌷🌹🥀🌺🌸🌼🌻🍀🌿🌱🪴🍁🍂🍃🪨🪵' },
{ id: 'food', icon: '🍎', name: 'Food & Drink',
chars: '🍇🍈🍉🍊🍋🍌🍍🥭🍎🍏🍐🍑🍒🍓🫐🥝🍅🫒🥥🥑🍆🥔🥕🌽🌶🫑🥒🥬🥦🧄🧅🍄🥜🫘🌰🍞🥐🥖🫓🥨🥯🥞🧇🧀🍖🍗🥩🥓🌭🍔🍟🍕🫔🥪🥙🧆🥚🍳🥘🍲🫕🥣🥗🍿🧈🍱🍘🍙🍚🍛🍜🍝🍠🍢🍣🍤🍥🥮🍡🥟🥠🥡🦪🍦🍧🍨🍩🍪🎂🍰🧁🥧🍫🍬🍭🍮🍯🍼🥛☕🫖🍵🧃🥤🧋🍶🍺🍻🥂🍷🥃🍸🍹🧉🍾🧊' },
{ id: 'travel', icon: '✈️', name: 'Travel & Places',
chars: '🌍🌎🌏🌐🗺🧭🏔⛰🌋🗻🏕🏖🏜🏝🏛🏗🛖🏠🏡🏢🏣🏤🏥🏦🏨🏩🏪🏫🏬🏭🏯🏰💒🗼🗽⛪🕌🛕🕍⛩🛣🌅🌄🌠🎇🎆🌃🌆🌇🌉🌌⛺🚗🚕🚙🚌🚎🏎🚓🚑🚒🚐🛻🚚🚛🚜🏍🛵🛺🚲🛴🛹🛼🚨🚥🚦🛑🚧⚓🛞🚢✈🛩🛫🛬🪂💺🚁🚀🛸' },
{ id: 'activities', icon: '⚽', name: 'Activities',
chars: '⚽🏀🏈⚾🥎🎾🏐🏉🥏🎱🏓🏸🏒⛳🎣🤿🎽🎿🛷🥌🎯🎰🎲🧩🧸🪅🪆🎭🎨🎪🎬🎤🎧🎼🎹🥁🪘🎷🎺🎸🪕🎻🪗🪈🎮🕹🃏🀄🎴🏆🥇🥈🥉🏅🎖🏵🎗🎫🎟' },
{ id: 'objects', icon: '💡', name: 'Objects',
chars: '💡🔦🕯🪔🧱🪜🧰🪛🔧🔨🛠⛏🪚🔩🪤🔗⛓🪝🧲🪣🧯🛢💈⚗🔭🔬🩺🩻💊💉🩹🩼🧫🧬🧪🩸🧹🧺🧻🚽🚿🛁🧴🧷🧼🫧🪥🛒📱💻🖥🖨⌨🖱💾💿📀🎥📸📷📹📞☎📺📻🧭⏱⏰🕰⌛⏳📡🔋🔌✉📧📦📫📮✏✒📝📁📂📅📆📌📍📢📣🔔🔕🎵🎶🪬🧿🪩🖼🎁🎀🎊🎋🎍🎎🎏🎐🎑' },
{ id: 'symbols', icon: '❤', name: 'Symbols',
chars: '❤🧡💛💚💙💜🖤🤍🤎💔💕💞💓💗💖💘💝💟☮✝☪🕉☸✡🔯☯⛎♈♉♊♋♌♍♎♏♐♑♒♓⚛☢☣🚫💯💢♨🌀🔱⚜〽✳❇🔰♻✅❌⭕🛑⛔📛⬆↗➡↘⬇↙⬅↖↕↔↩↪⤴⤵🔄⏩⏪⏫⏬▶⏸⏹⏺⏏🔀◀🔼🔽🟥🟧🟨🟩🟦🟪🟫⚫⚪🔴🟠🟡🟢🔵🟣🔶🔷🔸🔹🔺🔻💠🔘🔲🔳' },
{ id: 'flags', icon: '🚩', name: 'Flags',
chars: '🏁🚩🎌🏴🏳🇺🇸🇬🇧🇯🇵🇨🇳🇩🇪🇫🇷🇮🇹🇪🇸🇰🇷🇧🇷🇮🇳🇨🇦🇦🇺🇷🇺🇲🇽🇿🇦🇳🇬🇪🇬🇸🇦🇦🇷🇵🇹🇳🇱🇸🇪🇳🇴🇩🇰🇫🇮🇨🇭🇦🇹🇧🇪🇵🇱🇺🇦🇬🇷🇹🇷🇮🇱🇹🇼🇭🇰🇸🇬🇮🇩🇹🇭🇻🇳🇵🇭🇲🇾🇳🇿' },
{ id: 'zwj', icon: '👨👩👧', name: 'ZWJ Sequences(v2.0 / v2.3 重點支援)',
chars: '👨👩👧👨👩👦👨👩👧👦👩👩👧👩👩👦👨👨👧👨👨👦👩👧👦👩👧👩👦👨👧👦👩❤️👨👩❤️💋👨👮♀️👮♂️👷♀️👷♂️💂♀️💂♂️🕵️♀️🕵️♂️👩⚕️👨⚕️👩🏫👨🏫👩💻👨💻👩🎤👨🎤👩🍳👨🍳🏃♀️🏃♂️🚶♀️🚶♂️🧗♀️🧗♂️🧘♀️🧘♂️🧑🤝🧑🏳️🌈🏳️⚧️🏴☠️🐻❄️' },
];
// ── Nerd Fonts PUA sections ───────────────────────────────────────
const NERD_SECTIONS = [
{ id: 'powerline', name: 'Powerline Symbols', color: '#89dceb',
desc: 'prompt 分隔符、VCS 符號 — 1 欄寬(scale 500/2048)', range: [0xE0A0, 0xE0D7] },
{ id: 'devicons', name: 'Devicons', color: '#a6e3a1',
desc: '語言 / 框架 logo — 2 欄寬(scale 1000/2048)', range: [0xE700, 0xE7C5] },
{ id: 'codicons', name: 'Codicons (VS Code)', color: '#f9e2af',
desc: 'VS Code editor icons — 2 欄寬', range: [0xEA60, 0xEBEB] },
{ id: 'octicons', name: 'Octicons', color: '#cba6f7',
desc: 'GitHub / editor icons — 2 欄寬', range: [0xF400, 0xF4FF] },
];
// Variant definitions (order = left→right in the 4-col grid)
const VARIANTS = [
{ key: 'color', badgeCls: 'badge-color', fontCls: 'f-color', label: 'Color(彩色位圖)' },
{ key: 'lite', badgeCls: 'badge-lite', fontCls: 'f-lite', label: 'Lite(單色)' },
{ key: 'colrv1', badgeCls: 'badge-colrv1', fontCls: 'f-colrv1', label: 'COLRv1(向量 / 備援)' },
{ key: 'nerd', badgeCls: 'badge-nerd', fontCls: 'f-nerd', label: 'Nerd Lite(同 Lite)' },
];
// ── Utilities ─────────────────────────────────────────────────────
function graphemes(str) {
if (typeof Intl !== 'undefined' && Intl.Segmenter) {
return [...new Intl.Segmenter().segment(str)].map(s => s.segment);
}
return [...str];
}
// Return 'U+XXXX' for a single-codepoint grapheme cluster (optionally + VS).
// Returns null for ZWJ sequences / RI pairs (not in colrv1-emoji-list.json).
function baseCodepoint(ch) {
const cps = [...ch]; // ES6 iterator = code points
if (cps.length > 2) return null;
if (cps.length === 2) {
const vs = cps[1].codePointAt(0);
if (vs !== 0xFE0F && vs !== 0xFE0E) return null;
}
const cp = cps[0].codePointAt(0);
return 'U+' + cp.toString(16).toUpperCase().padStart(4, '0');
}
function rangeChars(start, end) {
let s = '';
for (let cp = start; cp <= end; cp++) s += String.fromCodePoint(cp);
return s;
}
function makeEl(tag, opts = {}) {
const el = document.createElement(tag);
if (opts.cls) el.className = opts.cls;
if (opts.text) el.textContent = opts.text;
if (opts.style) el.setAttribute('style', opts.style);
return el;
}
function td(text, cls) {
const c = document.createElement('td');
c.textContent = text;
if (cls) c.className = cls;
return c;
}
// ── COLRv1 data ───────────────────────────────────────────────────
async function loadColrv1() {
try {
const r = await fetch('docs/colrv1-emoji-list.json');
if (!r.ok) throw new Error('HTTP ' + r.status);
const d = await r.json();
return new Set(d.emoji.map(e => e.codepoint));
} catch (e) {
console.warn('variant-coverage: cannot load colrv1-emoji-list.json', e);
return new Set();
}
}
// ── Stats table ───────────────────────────────────────────────────
function buildStats(colrv1Set) {
const seg = typeof Intl !== 'undefined' && Intl.Segmenter ? new Intl.Segmenter() : null;
const tbody = document.getElementById('stats-body');
tbody.textContent = ''; // clear "載入中"
let sumTotal = 0, sumColored = 0;
for (const cat of CATEGORIES) {
const chars = graphemes(cat.chars);
const colored = chars.filter(ch => { const cp = baseCodepoint(ch); return cp && colrv1Set.has(cp); }).length;
sumTotal += chars.length;
sumColored += colored;
const row = tbody.insertRow();
row.appendChild(td(cat.icon + ' ' + cat.name));
row.appendChild(td(String(chars.length), 'n-all'));
row.appendChild(td('全部', 'n-all'));
row.appendChild(td('全部', 'n-all'));
row.appendChild(td(colored > 0 ? String(colored) : '0', colored > 0 ? 'n-colrv1' : 'n-dim'));
row.appendChild(td(String(chars.length - colored), 'n-dim'));
row.appendChild(td('全部', 'n-all'));
}
// Nerd PUA row
const nerdTotal = NERD_SECTIONS.reduce((s, n) => s + n.range[1] - n.range[0] + 1, 0);
const nerdRow = tbody.insertRow();
nerdRow.style.borderTop = '1px solid #45475a';
nerdRow.appendChild(td('🔧 Nerd Fonts PUA(4 集合)'));
['—', '—', '—', '—', '—'].forEach(v => nerdRow.appendChild(td(v, 'n-dim')));
const nNerd = document.createElement('td');
nNerd.textContent = '+' + nerdTotal;
nNerd.className = 'n-nerd';
nerdRow.appendChild(nNerd);
// Total row
const totRow = tbody.insertRow();
totRow.className = 'tfoot';
totRow.appendChild(td('合計(此頁樣本)'));
totRow.appendChild(td(String(sumTotal), 'n-all'));
totRow.appendChild(td(String(sumTotal), 'n-all'));
totRow.appendChild(td(String(sumTotal), 'n-all'));
totRow.appendChild(td(String(sumColored), 'n-colrv1'));
totRow.appendChild(td(String(sumTotal - sumColored), 'n-dim'));
const totNerd = document.createElement('td');
const a1 = document.createElement('span'); a1.className = 'n-all'; a1.textContent = String(sumTotal);
const a2 = document.createElement('span'); a2.className = 'n-nerd'; a2.textContent = '+' + nerdTotal;
totNerd.appendChild(a1);
totNerd.appendChild(document.createTextNode(' '));
totNerd.appendChild(a2);
totRow.appendChild(totNerd);
}
// ── Emoji variant column helper ───────────────────────────────────
function makeVcol(variant, emojiStr) {
const col = makeEl('div', { cls: 'vcol' });
// Header: "● Label"
const hd = makeEl('div', { cls: 'vcol-hd' });
const dot = makeEl('span', { cls: variant.badgeCls, text: '● ' });
hd.appendChild(dot);
hd.appendChild(document.createTextNode(variant.label));
col.appendChild(hd);
// Emoji display
const disp = makeEl('div', { cls: 'emoji-block ' + variant.fontCls, text: emojiStr });
col.appendChild(disp);
return col;
}
// ── Category sections ─────────────────────────────────────────────
function buildCategories(colrv1Set) {
const container = document.getElementById('cat-container');
CATEGORIES.forEach((cat, idx) => {
const chars = graphemes(cat.chars);
const colored = chars.filter(ch => { const cp = baseCodepoint(ch); return cp && colrv1Set.has(cp); }).length;
const colrv1Chars = chars.filter(ch => { const cp = baseCodepoint(ch); return cp && colrv1Set.has(cp); }).join('');
// <details>
const det = document.createElement('details');
if (idx < 3) det.open = true;
det.dataset.group = 'emoji';
// <summary>
const sum = document.createElement('summary');
sum.appendChild(document.createTextNode(cat.icon + ' ' + cat.name));
const meta = makeEl('span', { cls: 'cat-meta' });
const nAll = makeEl('span', { cls: 'n-all', text: chars.length + ' 個' });
meta.appendChild(nAll);
if (colored > 0) {
meta.appendChild(document.createTextNode(' | COLRv1 向量 '));
meta.appendChild(makeEl('span', { cls: 'n-colrv1', text: String(colored) }));
}
sum.appendChild(meta);
det.appendChild(sum);
// 4-col grid
const grid = makeEl('div', { cls: 'vgrid' });
for (const v of VARIANTS) {
const col = makeVcol(v, cat.chars);
// COLRv1 column: append sub-row for vector-colored chars
if (v.key === 'colrv1' && colrv1Chars) {
const sub = makeEl('div', { cls: 'colrv1-sub' });
sub.appendChild(makeEl('div', { cls: 'colrv1-sub-label', text: '▸ 向量彩色(' + colored + ' 個)' }));
sub.appendChild(makeEl('div', { cls: 'emoji-block f-colrv1', text: colrv1Chars }));
col.appendChild(sub);
}
grid.appendChild(col);
}
det.appendChild(grid);
container.appendChild(det);
});
}
// ── Nerd PUA section ──────────────────────────────────────────────
function buildNerd() {
const container = document.getElementById('nerd-container');
for (const sec of NERD_SECTIONS) {
const chars = rangeChars(sec.range[0], sec.range[1]);
const count = sec.range[1] - sec.range[0] + 1;
const rangeStr = 'U+' + sec.range[0].toString(16).toUpperCase()
+ ' – U+' + sec.range[1].toString(16).toUpperCase();
const det = document.createElement('details');
det.open = true;
det.dataset.group = 'nerd';
// summary
const sum = document.createElement('summary');
const nameSpan = makeEl('span', { text: sec.name, style: 'color:' + sec.color });
sum.appendChild(nameSpan);
const meta = makeEl('span', { cls: 'cat-meta' });
meta.appendChild(makeEl('span', { cls: 'n-nerd', text: count + ' 個' }));
meta.appendChild(document.createTextNode(' | ' + sec.desc));
sum.appendChild(meta);
det.appendChild(sum);
// 2-col grid
const grid = makeEl('div', { cls: 'ngrid' });
// Nerd Lite column
const nCol = makeEl('div', { cls: 'ncol' });
const nHd = makeEl('div', { cls: 'ncol-hd', style: 'color:' + sec.color,
text: 'Nerd Lite(應顯示圖示)' });
const nDisp = makeEl('div', { cls: 'emoji-block f-nerd', text: chars });
const nInfo = makeEl('div', { cls: 'range-info',
text: rangeStr + ' | ' + count + ' codepoints' });
nCol.appendChild(nHd);
nCol.appendChild(nDisp);
nCol.appendChild(nInfo);
// Lite compare column
const lCol = makeEl('div', { cls: 'ncol' });
const lHd = makeEl('div', { cls: 'ncol-hd', style: 'color:#6c7086',
text: 'Lite 對照(□ = 正常缺字)' });
const lDisp = makeEl('div', { cls: 'emoji-block f-lite', text: chars });
lCol.appendChild(lHd);
lCol.appendChild(lDisp);
grid.appendChild(nCol);
grid.appendChild(lCol);
det.appendChild(grid);
container.appendChild(det);
}
}
// ── Expand / collapse ─────────────────────────────────────────────
function setAll(open, group) {
document.querySelectorAll('details[data-group="' + group + '"]')
.forEach(d => { d.open = open; });
}
// ── Font status checker ───────────────────────────────────────────
const FONT_DEFS = [
{ family: 'OutColor', label: 'Color', badge: 'badge-color',
path: 'output/fonts/SarasaMonoTCEmoji-Regular.ttf' },
{ family: 'OutLite', label: 'Lite', badge: 'badge-lite',
path: 'output/fonts-lite/SarasaMonoTCEmojiLite-Regular.ttf' },
{ family: 'OutCOLRv1', label: 'COLRv1', badge: 'badge-colrv1',
path: 'output/fonts-colrv1/SarasaMonoTCEmojiCOLRv1-Regular.ttf' },
{ family: 'OutNerd', label: 'Nerd Lite', badge: 'badge-nerd',
path: 'output/fonts-nerd-lite/SarasaMonoTCEmojiLiteNerd-Regular.ttf' },
];
async function buildFontStatus() {
const tbody = document.getElementById('font-status-body');
// Insert rows immediately (loading state)
const rows = FONT_DEFS.map(f => {
const row = document.createElement('tr');
const tdLabel = document.createElement('td');
const badge = makeEl('span', { cls: f.badge, text: '● ' + f.label });
tdLabel.appendChild(badge);
row.appendChild(tdLabel);
const tdPath = document.createElement('td');
tdPath.appendChild(makeEl('code', { text: f.path }));
row.appendChild(tdPath);
const tdStatus = makeEl('td', { cls: 'fs-loading', text: '確認中…' });
row.appendChild(tdStatus);
tbody.appendChild(row);
return { f, tdStatus };
});
// Wait for fonts, then update status
await document.fonts.ready;
for (const { f, tdStatus } of rows) {
try {
const loaded = await document.fonts.load('20px "' + f.family + '"');
if (loaded.length > 0) {
tdStatus.textContent = '✓ 已載入';
tdStatus.className = 'fs-ok';
} else {
tdStatus.textContent = '✗ 未找到(請先執行 build.py)';
tdStatus.className = 'fs-err';
}
} catch (e) {
tdStatus.textContent = '✗ 載入失敗:' + e.message;
tdStatus.className = 'fs-err';
}
}
}
// ── Main ──────────────────────────────────────────────────────────
(async () => {
buildFontStatus(); // fire-and-forget: updates status independently
const colrv1Set = await loadColrv1();
buildStats(colrv1Set);
buildCategories(colrv1Set);
buildNerd();
})();
</script>
</body>
</html>