//! Cut the bundled face, rather than commit one. //! //! The house face is cut from a pinned base by `quasi-type`, and cutting it //! here is what keeps the glyph set and the shipped face from drifting apart: a //! face in the repo would be a second source of truth that nothing rebuilds. //! //! The base is downloaded once into `OUT_DIR` and checksummed against //! `quasi-type`'s pins, so a warm target directory needs no network. //! //! A cold one reaches raw.githubusercontent.com, which rate-limits by IP and //! can fail a container image build. `QUASI_TYPE_MIRROR` in the environment //! names a base URL that is tried first, with the pinned url as the fallback; //! every file is addressed under it by the sha256 the pin already carries, so a //! mirror is a second source rather than a second thing to trust. Nothing here //! reads it: it is `quasi-type`'s own knob, and setting it is what lets a build //! host cover this fetch without shop changing. fn main() { println!("cargo:rerun-if-changed=build.rs"); let out = std::path::PathBuf::from(std::env::var("OUT_DIR").expect("cargo sets OUT_DIR")); // cut_native writes the ttf and the OFL text and hands back what has to be // exported beside them. let written = match quasi_type::cut_native( &out, &out.join("bases"), false, &[("quasi-mono", "face.ttf")], ) { Ok(written) => written, Err(e) => panic!( "could not cut the bundled face: {e}\n\ The base is fetched from its pinned url on the first build and cached in \ OUT_DIR after that, so this needs network once per target directory." ), }; let face = written .first() .unwrap_or_else(|| panic!("quasi-mono cut no faces")); // Both paths come back from cut_native rather than being spelled again here: // the licence file is named for the family (`OFL-QuasiMono.txt`), and a // second spelling of that is a rename away from a build failure. println!("cargo:rustc-env=SHOP_FONT_FACE={}", face.path.display()); println!( "cargo:rustc-env=SHOP_FONT_LICENSE={}", face.license_path.display() ); println!("cargo:rustc-env=SHOP_FONT_FAMILY={}", face.family); println!("cargo:rustc-env=SHOP_FONT_STYLE={}", face.style); // The style is the base's default instance and is not always `Regular`: // Atkinson Mono's is `ExtraLight`, which is the whole reason shop names a // weight when it renders rather than taking what the file opens at. println!( "cargo:rustc-env=SHOP_FONT_DEFAULT_WEIGHT={}", face.default_weight ); }