| 140 |
140 |
|
"static/geometry.css",
|
| 141 |
141 |
|
"static/layout.css",
|
| 142 |
142 |
|
"static/embed-geometry.css",
|
|
143 |
+ |
// The tokens and the @font-face rules. Note what this does NOT cover:
|
|
144 |
+ |
// the woff2 files themselves are served under fixed names with no `?v=`,
|
|
145 |
+ |
// so a re-cut of the same slot ships new bytes at an old URL and a
|
|
146 |
+ |
// browser holding a cached copy keeps it. That was equally true of the
|
|
147 |
+ |
// Plex and Lato files this replaced, and a face changes about as often
|
|
148 |
+ |
// as the glyph set version does, so it is a known edge rather than a
|
|
149 |
+ |
// regression. The fix, if it ever bites, is a version in the URL
|
|
150 |
+ |
// makeover is handed.
|
|
151 |
+ |
"static/typography.css",
|
| 143 |
152 |
|
] {
|
| 144 |
153 |
|
if let Ok(content) = fs::read(path) {
|
| 145 |
154 |
|
content.hash(&mut hasher);
|
| 184 |
193 |
|
/// finds out until a mark looks wrong. The pipeline is the source; these are
|
| 185 |
194 |
|
/// its output, and they are gitignored.
|
| 186 |
195 |
|
///
|
| 187 |
|
- |
/// # woff2 only, and no ttf beside it
|
| 188 |
|
- |
///
|
| 189 |
|
- |
/// The old pairs here offered `woff2` with a `truetype` fallback, which was
|
| 190 |
|
- |
/// already dead weight: every browser that can run this site has supported
|
| 191 |
|
- |
/// woff2 since 2018, and the ttf is 2-3x the bytes for a case that does not
|
| 192 |
|
- |
/// arrive. `makeover::font_face_css` declares woff2 alone, so writing a ttf
|
| 193 |
|
- |
/// would put a file in `static/` that nothing ever fetches.
|
| 194 |
|
- |
///
|
| 195 |
|
- |
/// # The base is fetched once
|
| 196 |
|
- |
///
|
| 197 |
|
- |
/// `quasi_type::cut` downloads the pinned base into the cache directory below
|
| 198 |
|
- |
/// and checksums it, so a warm target directory needs no network. `offline` is
|
| 199 |
|
- |
/// false because the first build on a fresh machine has to be able to fetch;
|
| 200 |
|
- |
/// a failure here is fatal rather than skipped, since a missing face is a site
|
|
196 |
+ |
/// The base is downloaded into `OUT_DIR` once and checksummed against
|
|
197 |
+ |
/// quasi-type's pins, so a warm target directory needs no network. `offline` is
|
|
198 |
+ |
/// false because the first build on a fresh machine has to be able to fetch,
|
|
199 |
+ |
/// and a failure here is fatal rather than skipped: a missing face is a site
|
| 201 |
200 |
|
/// rendering in the fallback with nothing to say so.
|
| 202 |
201 |
|
fn cut_house_faces() {
|
| 203 |
|
- |
let dir = Path::new("static/fonts");
|
| 204 |
|
- |
fs::create_dir_all(dir).expect("create static/fonts");
|
| 205 |
202 |
|
let cache = Path::new(&std::env::var("OUT_DIR").expect("cargo sets OUT_DIR")).join("bases");
|
| 206 |
|
- |
|
| 207 |
|
- |
for (slot, file) in [
|
| 208 |
|
- |
("quasi-mono", makeover_build::WEBFONT_MONO_FILE),
|
| 209 |
|
- |
("quasi-body", makeover_build::WEBFONT_SANS_FILE),
|
| 210 |
|
- |
] {
|
| 211 |
|
- |
let cut = quasi_type::cut(slot, &cache, false)
|
| 212 |
|
- |
.unwrap_or_else(|e| panic!("could not cut {slot}: {e}"));
|
| 213 |
|
- |
let face = cut
|
| 214 |
|
- |
.faces
|
| 215 |
|
- |
.first()
|
| 216 |
|
- |
.unwrap_or_else(|| panic!("{slot} cut no faces"));
|
| 217 |
|
- |
// One file per slot, and it carries the whole `wght` 200-800 axis. The
|
| 218 |
|
- |
// four static files this replaces (Plex Mono and Lato, regular and
|
| 219 |
|
- |
// bold) were 101 KB of woff2 between them and covered two weights.
|
| 220 |
|
- |
write_bytes_if_changed(&dir.join(file), &face.woff2);
|
| 221 |
|
- |
write_bytes_if_changed(
|
| 222 |
|
- |
&dir.join(format!("OFL-{}.txt", cut.family.replace(' ', ""))),
|
| 223 |
|
- |
&cut.license,
|
| 224 |
|
- |
);
|
| 225 |
|
- |
}
|
| 226 |
|
- |
}
|
| 227 |
|
- |
|
| 228 |
|
- |
/// `write_if_changed` for bytes.
|
| 229 |
|
- |
///
|
| 230 |
|
- |
/// Same reason as the text version: rewriting an identical file bumps its mtime
|
| 231 |
|
- |
/// and makes every downstream step think the fonts moved.
|
| 232 |
|
- |
fn write_bytes_if_changed(path: &Path, contents: &[u8]) {
|
| 233 |
|
- |
if fs::read(path).is_ok_and(|existing| existing == contents) {
|
| 234 |
|
- |
return;
|
| 235 |
|
- |
}
|
| 236 |
|
- |
fs::write(path, contents).unwrap_or_else(|e| panic!("write {}: {e}", path.display()));
|
|
203 |
+ |
quasi_type::cut_web(
|
|
204 |
+ |
Path::new("static/fonts"),
|
|
205 |
+ |
&cache,
|
|
206 |
+ |
false,
|
|
207 |
+ |
&[
|
|
208 |
+ |
("quasi-mono", makeover_build::WEBFONT_MONO_FILE),
|
|
209 |
+ |
("quasi-body", makeover_build::WEBFONT_SANS_FILE),
|
|
210 |
+ |
],
|
|
211 |
+ |
)
|
|
212 |
+ |
.expect("cut the house faces");
|
| 237 |
213 |
|
}
|
| 238 |
214 |
|
|
| 239 |
215 |
|
/// Intrinsic dimensions of the landing screenshots, read from the files.
|