|
| 1 | +<!doctype html> |
| 2 | +<html lang="en"> |
| 3 | +<head> |
| 4 | +<meta charset="utf-8"> |
| 5 | +<meta name="viewport" content="width=device-width, initial-scale=1"> |
| 6 | +<title>fontpkg — fonts as Python dependencies</title> |
| 7 | +<style> |
| 8 | +:root { |
| 9 | + --bg: #fafaf8; --fg: #1a1a1a; --muted: #6b6b6b; --card: #ffffff; |
| 10 | + --border: #e4e2dd; --accent: #2563eb; --accent-fg: #ffffff; --chip: #efede8; |
| 11 | +} |
| 12 | +@media (prefers-color-scheme: dark) { |
| 13 | + :root { |
| 14 | + --bg: #12110f; --fg: #ececec; --muted: #9a9a9a; --card: #1c1b18; |
| 15 | + --border: #2e2c28; --accent: #3b82f6; --accent-fg: #ffffff; --chip: #262420; |
| 16 | + } |
| 17 | +} |
| 18 | +* { box-sizing: border-box; } |
| 19 | +body { |
| 20 | + margin: 0; background: var(--bg); color: var(--fg); |
| 21 | + font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; |
| 22 | +} |
| 23 | +header { max-width: 1100px; margin: 0 auto; padding: 2.5rem 1.25rem 0; } |
| 24 | +h1 { font-size: 1.6rem; margin: 0 0 .25rem; } |
| 25 | +h1 code { font-family: ui-monospace, monospace; } |
| 26 | +.tagline { color: var(--muted); margin: 0 0 1.5rem; } |
| 27 | +.tagline a { color: var(--accent); text-decoration: none; } |
| 28 | +.controls { |
| 29 | + max-width: 1100px; margin: 0 auto; padding: 0 1.25rem 1rem; |
| 30 | + display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; |
| 31 | + position: sticky; top: 0; background: var(--bg); padding-top: 1rem; z-index: 5; |
| 32 | + border-bottom: 1px solid var(--border); |
| 33 | +} |
| 34 | +.controls input[type="text"] { |
| 35 | + background: var(--card); color: var(--fg); border: 1px solid var(--border); |
| 36 | + border-radius: 8px; padding: .55rem .8rem; font-size: 1rem; |
| 37 | +} |
| 38 | +#search { width: 14rem; } |
| 39 | +#preview { flex: 1 1 16rem; } |
| 40 | +.chips { display: flex; gap: .4rem; flex-wrap: wrap; } |
| 41 | +.chip { |
| 42 | + background: var(--chip); border: 1px solid var(--border); color: var(--fg); |
| 43 | + border-radius: 999px; padding: .3rem .8rem; font-size: .85rem; cursor: pointer; |
| 44 | +} |
| 45 | +.chip.active { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); } |
| 46 | +.slider-group { display: flex; align-items: center; gap: .5rem; font-size: .85rem; color: var(--muted); } |
| 47 | +.grid { |
| 48 | + max-width: 1100px; margin: 0 auto; padding: 1.25rem; |
| 49 | + display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1rem; |
| 50 | +} |
| 51 | +.card { |
| 52 | + background: var(--card); border: 1px solid var(--border); border-radius: 12px; |
| 53 | + padding: 1.1rem 1.25rem; display: flex; flex-direction: column; gap: .6rem; |
| 54 | +} |
| 55 | +.card .meta { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; } |
| 56 | +.card .name { font-weight: 600; } |
| 57 | +.card .info { color: var(--muted); font-size: .78rem; text-align: right; } |
| 58 | +.card .sample { |
| 59 | + font-size: 1.9rem; line-height: 1.25; min-height: 3.2rem; overflow-wrap: anywhere; |
| 60 | + outline: none; border: none; padding: 0; background: none; color: var(--fg); |
| 61 | +} |
| 62 | +.card .install { |
| 63 | + display: flex; align-items: center; gap: .5rem; margin-top: auto; |
| 64 | +} |
| 65 | +.card .install code { |
| 66 | + font-family: ui-monospace, monospace; font-size: .82rem; color: var(--muted); |
| 67 | + background: var(--chip); border-radius: 6px; padding: .3rem .55rem; flex: 1; |
| 68 | + overflow-x: auto; white-space: nowrap; |
| 69 | +} |
| 70 | +.card .install button { |
| 71 | + background: none; border: 1px solid var(--border); color: var(--muted); |
| 72 | + border-radius: 6px; padding: .28rem .6rem; font-size: .78rem; cursor: pointer; |
| 73 | +} |
| 74 | +.card .install button:hover { color: var(--fg); border-color: var(--muted); } |
| 75 | +#empty { max-width: 1100px; margin: 2rem auto; padding: 0 1.25rem; color: var(--muted); display: none; } |
| 76 | +footer { |
| 77 | + max-width: 1100px; margin: 2rem auto 3rem; padding: 0 1.25rem; |
| 78 | + color: var(--muted); font-size: .85rem; |
| 79 | +} |
| 80 | +footer a { color: var(--accent); text-decoration: none; } |
| 81 | +/*__FONT_FACES__*/ |
| 82 | +</style> |
| 83 | +</head> |
| 84 | +<body> |
| 85 | +<header> |
| 86 | + <h1><code>fontpkg</code></h1> |
| 87 | + <p class="tagline">Fonts as ordinary Python dependencies. |
| 88 | + Every specimen below renders from the exact font file the package installs. |
| 89 | + <a href="https://github.com/Fontpkg/fontpkg">GitHub</a> · |
| 90 | + <a href="https://pypi.org/project/fontpkg/">PyPI</a></p> |
| 91 | +</header> |
| 92 | +<div class="controls"> |
| 93 | + <input id="search" type="text" placeholder="Filter families… (e.g. got)"> |
| 94 | + <div class="chips" id="categories"></div> |
| 95 | + <input id="preview" type="text" placeholder="Type to preview in every font…"> |
| 96 | + <span class="slider-group"> |
| 97 | + <label for="weight">weight <b id="weight-val">400</b></label> |
| 98 | + <input id="weight" type="range" min="100" max="900" step="10" value="400"> |
| 99 | + <label><input id="italic" type="checkbox"> italic</label> |
| 100 | + </span> |
| 101 | +</div> |
| 102 | +<div class="grid" id="grid"></div> |
| 103 | +<p id="empty">No families match. The catalog grows weekly — request one on |
| 104 | + <a href="https://github.com/Fontpkg/fontpkg/issues">GitHub</a>.</p> |
| 105 | +<footer> |
| 106 | + Fonts are redistributed unmodified under their own licenses (OFL-1.1 / Apache-2.0), |
| 107 | + packaged from <a href="https://github.com/google/fonts">google/fonts</a>. |
| 108 | + Inspired by <a href="https://fontsource.org">Fontsource</a>. |
| 109 | +</footer> |
| 110 | +<script> |
| 111 | +const FAMILIES = __FAMILY_DATA__; |
| 112 | +const DEFAULT_TEXT = "Grumpy wizards make toxic brew for the evil queen and jack."; |
| 113 | +const CATEGORY_LABELS = { |
| 114 | + SANS_SERIF: "Sans", SERIF: "Serif", MONOSPACE: "Mono", |
| 115 | + DISPLAY: "Display", HANDWRITING: "Handwriting", |
| 116 | +}; |
| 117 | +const state = { query: "", category: "ALL", text: "", weight: 400, italic: false }; |
| 118 | + |
| 119 | +const grid = document.getElementById("grid"); |
| 120 | +const cards = new Map(); |
| 121 | +const lazyLoader = new IntersectionObserver((entries) => { |
| 122 | + for (const entry of entries) { |
| 123 | + if (!entry.isIntersecting) continue; |
| 124 | + const { sample, fam } = cards.get(entry.target.dataset.slug); |
| 125 | + sample.style.fontFamily = `"${fam.family}"`; |
| 126 | + lazyLoader.unobserve(entry.target); |
| 127 | + } |
| 128 | +}, { rootMargin: "300px" }); |
| 129 | + |
| 130 | +function clamp(value, range) { |
| 131 | + if (!range) return value; |
| 132 | + return Math.min(Math.max(value, range[0]), range[1]); |
| 133 | +} |
| 134 | + |
| 135 | +function buildCard(fam) { |
| 136 | + const card = document.createElement("div"); |
| 137 | + card.className = "card"; |
| 138 | + const range = fam.weight_range ? `${fam.weight_range[0]}–${fam.weight_range[1]}` : ""; |
| 139 | + const kind = fam.variable ? `variable ${range}` : `${fam.weights.length} weights`; |
| 140 | + card.innerHTML = ` |
| 141 | + <div class="meta"> |
| 142 | + <span class="name">${fam.family}</span> |
| 143 | + <span class="info">${fam.license} · ${kind}</span> |
| 144 | + </div> |
| 145 | + <div class="sample" contenteditable="true" spellcheck="false"></div> |
| 146 | + <div class="install"> |
| 147 | + <code>uv add ${fam.package}</code> |
| 148 | + <button type="button">copy</button> |
| 149 | + </div>`; |
| 150 | + const sample = card.querySelector(".sample"); |
| 151 | + card.dataset.slug = fam.slug; |
| 152 | + lazyLoader.observe(card); |
| 153 | + sample.addEventListener("input", () => { sample.dataset.custom = "1"; }); |
| 154 | + const button = card.querySelector("button"); |
| 155 | + button.addEventListener("click", async () => { |
| 156 | + await navigator.clipboard.writeText(`uv add ${fam.package}`); |
| 157 | + button.textContent = "copied!"; |
| 158 | + setTimeout(() => { button.textContent = "copy"; }, 1200); |
| 159 | + }); |
| 160 | + cards.set(fam.slug, { card, sample, fam }); |
| 161 | + return card; |
| 162 | +} |
| 163 | + |
| 164 | +function applyText() { |
| 165 | + const text = state.text || DEFAULT_TEXT; |
| 166 | + for (const { sample } of cards.values()) { |
| 167 | + if (!sample.dataset.custom) sample.textContent = text; |
| 168 | + } |
| 169 | +} |
| 170 | + |
| 171 | +function applyStyle() { |
| 172 | + for (const { sample, fam } of cards.values()) { |
| 173 | + const weight = clamp(state.weight, fam.weight_range); |
| 174 | + sample.style.fontWeight = weight; |
| 175 | + const italic = state.italic && fam.styles.includes("italic"); |
| 176 | + sample.style.fontStyle = italic ? "italic" : "normal"; |
| 177 | + } |
| 178 | +} |
| 179 | + |
| 180 | +function applyFilter() { |
| 181 | + const q = state.query.trim().toLowerCase(); |
| 182 | + let visible = 0; |
| 183 | + for (const { card, fam } of cards.values()) { |
| 184 | + const matchesQuery = |
| 185 | + !q || fam.family.toLowerCase().includes(q) || fam.slug.includes(q); |
| 186 | + const matchesCategory = |
| 187 | + state.category === "ALL" || (fam.category || []).includes(state.category); |
| 188 | + const show = matchesQuery && matchesCategory; |
| 189 | + card.style.display = show ? "" : "none"; |
| 190 | + if (show) visible += 1; |
| 191 | + } |
| 192 | + document.getElementById("empty").style.display = visible ? "none" : "block"; |
| 193 | +} |
| 194 | + |
| 195 | +const seen = new Set(FAMILIES.flatMap((f) => f.category || [])); |
| 196 | +const chipHost = document.getElementById("categories"); |
| 197 | +const chips = [["ALL", "All"], ...Object.entries(CATEGORY_LABELS).filter(([k]) => seen.has(k))]; |
| 198 | +for (const [value, label] of chips) { |
| 199 | + const chip = document.createElement("button"); |
| 200 | + chip.className = "chip" + (value === "ALL" ? " active" : ""); |
| 201 | + chip.textContent = label; |
| 202 | + chip.addEventListener("click", () => { |
| 203 | + state.category = value; |
| 204 | + chipHost.querySelectorAll(".chip").forEach((c) => c.classList.remove("active")); |
| 205 | + chip.classList.add("active"); |
| 206 | + applyFilter(); |
| 207 | + }); |
| 208 | + chipHost.appendChild(chip); |
| 209 | +} |
| 210 | + |
| 211 | +for (const fam of FAMILIES) grid.appendChild(buildCard(fam)); |
| 212 | +applyText(); |
| 213 | +applyStyle(); |
| 214 | +applyFilter(); |
| 215 | + |
| 216 | +document.getElementById("search").addEventListener("input", (e) => { |
| 217 | + state.query = e.target.value; |
| 218 | + applyFilter(); |
| 219 | +}); |
| 220 | +document.getElementById("preview").addEventListener("input", (e) => { |
| 221 | + state.text = e.target.value; |
| 222 | + for (const { sample } of cards.values()) delete sample.dataset.custom; |
| 223 | + applyText(); |
| 224 | +}); |
| 225 | +document.getElementById("weight").addEventListener("input", (e) => { |
| 226 | + state.weight = Number(e.target.value); |
| 227 | + document.getElementById("weight-val").textContent = e.target.value; |
| 228 | + applyStyle(); |
| 229 | +}); |
| 230 | +document.getElementById("italic").addEventListener("change", (e) => { |
| 231 | + state.italic = e.target.checked; |
| 232 | + applyStyle(); |
| 233 | +}); |
| 234 | +</script> |
| 235 | +</body> |
| 236 | +</html> |
0 commit comments