Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
412 changes: 412 additions & 0 deletions dashboard/cells/raphina/fonts/OFL.txt

Large diffs are not rendered by default.

Binary file added dashboard/cells/raphina/fonts/ja.woff2
Binary file not shown.
Binary file added dashboard/cells/raphina/fonts/ko-400.woff2
Binary file not shown.
Binary file added dashboard/cells/raphina/fonts/ko-700.woff2
Binary file not shown.
Binary file added dashboard/cells/raphina/fonts/latin.woff2
Binary file not shown.
81 changes: 81 additions & 0 deletions dashboard/cells/raphina/fonts/subset.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
"""Rebuild the font subsets in this folder from ../index.html.

Run after you add winners to AWARDS:
pip install fonttools brotli
python subset.py <dir with the source .ttf files>

Source fonts (SIL OFL, from github.com/google/fonts/tree/main/ofl):
JetBrainsMono[wght].ttf, NotoSansJP[wght].ttf, NotoSansSC[wght].ttf,
NanumGothicCoding-Regular.ttf, NanumGothicCoding-Bold.ttf
"""
import re
import sys
from pathlib import Path

from fontTools import subset

HERE = Path(__file__).resolve().parent
CJK = 0x2E80 # first code point of the CJK blocks

# source file -> (output file, which characters it gets)
FONTS = {
"JetBrainsMono[wght].ttf": ("latin.woff2", "latin"),
"NotoSansJP[wght].ttf": ("ja.woff2", "ja"),
"NotoSansSC[wght].ttf": ("zh.woff2", "zh"),
"NanumGothicCoding-Regular.ttf": ("ko-400.woff2", "ko"),
"NanumGothicCoding-Bold.ttf": ("ko-700.woff2", "ko"),
}


# A subset is a modified font, and the OFL forbids giving it a Reserved Font
# Name. Nanum Gothic Coding reserves "Nanum" and "NanumGothic", so its subsets
# get a new name (also used in index.html). See OFL.txt.
RENAME = {
"NanumGothicCoding-Regular.ttf": ("Coding KR", "Regular"),
"NanumGothicCoding-Bold.ttf": ("Coding KR", "Bold"),
}


def rename(font, names):
family, style = names
ps = f"{family.replace(' ', '')}-{style}"
for nid, value in {1: family, 3: ps, 4: f"{family} {style}", 6: ps, 16: family}.items():
font["name"].removeNames(nameID=nid)
font["name"].setName(value, nid, 3, 1, 0x409)


def chars_by_lang(html):
"""Group the CJK characters of each AWARDS entry by its lang tag."""
groups = {"latin": set(map(chr, range(0x20, 0x7F)))}
lang = None
for line in html.splitlines():
m = re.search(r"lang: '(\w+)'", line)
if m:
lang = m.group(1)
for c in line:
if ord(c) < CJK:
groups["latin"].add(c)
elif lang:
groups.setdefault(lang, set()).add(c)
return groups


def main(src):
groups = chars_by_lang((HERE.parent / "index.html").read_text("utf-8"))
for name, (out, group) in FONTS.items():
opts = subset.Options()
opts.flavor = "woff2"
opts.layout_features = ["*"]
opts.name_IDs = ["*"] # keep the copyright and OFL license entries
font = subset.load_font(str(Path(src) / name), opts)
sub = subset.Subsetter(opts)
sub.populate(text="".join(sorted(groups.get(group, ()))))
sub.subset(font)
if name in RENAME:
rename(font, RENAME[name])
subset.save_font(font, str(HERE / out), opts)
print(f"{out}: {len(groups.get(group, ()))} chars, {(HERE / out).stat().st_size // 1024} KB")


if __name__ == "__main__":
main(sys.argv[1])
Binary file added dashboard/cells/raphina/fonts/zh.woff2
Binary file not shown.
15 changes: 14 additions & 1 deletion dashboard/cells/raphina/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,25 @@
--bg: #0b120d; --ink: #d8f5e0; --ink-2: #8fbf9f; --ink-3: #55805f;
--green: #35e07c; --green-dim: #1f9e57; --amber: #e0b435; --line: #1d3323;
}
/* subsets of the glyphs in AWARDS, so the TV needs no local CJK fonts
("Coding KR" is Nanum Gothic Coding, renamed as its OFL requires; see fonts/OFL.txt);
rebuild with fonts/subset.py after you add winners */
@font-face { font-family: "JetBrains Mono"; src: url(fonts/latin.woff2) format("woff2"); font-weight: 100 900; }
@font-face { font-family: "Noto Sans JP"; src: url(fonts/ja.woff2) format("woff2"); font-weight: 100 900; }
@font-face { font-family: "Noto Sans SC"; src: url(fonts/zh.woff2) format("woff2"); font-weight: 100 900; }
@font-face { font-family: "Coding KR"; src: url(fonts/ko-400.woff2) format("woff2"); font-weight: 400; }
@font-face { font-family: "Coding KR"; src: url(fonts/ko-700.woff2) format("woff2"); font-weight: 700; }
:root { --mono: ui-monospace, "SF Mono", Menlo, Consolas, "JetBrains Mono"; }
* { margin: 0; box-sizing: border-box; }
body {
background: var(--bg); color: var(--ink);
font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
font-family: var(--mono), "Noto Sans SC", "Noto Sans JP", "Coding KR", monospace;
height: 100vh; overflow: hidden;
}
/* the script sets lang per award; Han glyph shapes differ between ja and zh */
:lang(ja) { font-family: var(--mono), "Noto Sans JP", monospace; }
:lang(zh) { font-family: var(--mono), "Noto Sans SC", monospace; }
:lang(ko) { font-family: var(--mono), "Coding KR", monospace; }
#stars { position: fixed; inset: 0; width: 100%; height: 100%; }
/* sized against the cell's own frame (container units), so the timeline
fills the fullscreen monitor scene and stays compact in the grid tile */
Expand Down
5 changes: 5 additions & 0 deletions dashboard/cells/raphina/prompt.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,8 @@ news reports, and publisher or SFE records for English editions. Years with
no award are left out. Zajdel years are publication years. Not yet found:
2026 SF어워드 and 2026 华语科幻星云奖. Add new winners to `AWARDS` in
`index.html` after each ceremony.

Fonts: the cell ships its own font subsets in `fonts/` (JetBrains Mono, Noto
Sans JP, Noto Sans SC, Nanum Gothic Coding; SIL OFL), so CJK titles render on
the department TV. After you add winners, run `fonts/subset.py` to add the new
glyphs.
Loading