max / shop
| 1 | //! Cut the bundled face, rather than commit one. |
| 2 | //! |
| 3 | //! The house face is cut from a pinned base by `quasi-type`, and cutting it |
| 4 | //! here is what keeps the glyph set and the shipped face from drifting apart: a |
| 5 | //! face in the repo would be a second source of truth that nothing rebuilds. |
| 6 | //! |
| 7 | //! The base is downloaded once into `OUT_DIR` and checksummed against |
| 8 | //! `quasi-type`'s pins, so a warm target directory needs no network. |
| 9 | //! |
| 10 | //! A cold one reaches raw.githubusercontent.com, which rate-limits by IP and |
| 11 | //! can fail a container image build. `QUASI_TYPE_MIRROR` in the environment |
| 12 | //! names a base URL that is tried first, with the pinned url as the fallback; |
| 13 | //! every file is addressed under it by the sha256 the pin already carries, so a |
| 14 | //! mirror is a second source rather than a second thing to trust. Nothing here |
| 15 | //! reads it: it is `quasi-type`'s own knob, and setting it is what lets a build |
| 16 | //! host cover this fetch without shop changing. |
| 17 | |
| 18 | |
| 19 | println!; |
| 20 | |
| 21 | let out = from; |
| 22 | // cut_native writes the ttf and the OFL text and hands back what has to be |
| 23 | // exported beside them. |
| 24 | let written = match cut_native |
| 25 | &out, |
| 26 | &out.join, |
| 27 | false, |
| 28 | &, |
| 29 | |
| 30 | Ok => written, |
| 31 | Err => panic! |
| 32 | "could not cut the bundled face: {e}\n\ |
| 33 | The base is fetched from its pinned url on the first build and cached in \ |
| 34 | OUT_DIR after that, so this needs network once per target directory." |
| 35 | , |
| 36 | ; |
| 37 | let face = written |
| 38 | .first |
| 39 | .unwrap_or_else; |
| 40 | |
| 41 | // Both paths come back from cut_native rather than being spelled again here: |
| 42 | // the licence file is named for the family (`OFL-QuasiMono.txt`), and a |
| 43 | // second spelling of that is a rename away from a build failure. |
| 44 | println!; |
| 45 | println! |
| 46 | "cargo:rustc-env=SHOP_FONT_LICENSE={}" |
| 47 | face.license_path.display |
| 48 | ); |
| 49 | println!; |
| 50 | println!; |
| 51 | // The style is the base's default instance and is not always `Regular`: |
| 52 | // Atkinson Mono's is `ExtraLight`, which is the whole reason shop names a |
| 53 | // weight when it renders rather than taking what the file opens at. |
| 54 | println! |
| 55 | "cargo:rustc-env=SHOP_FONT_DEFAULT_WEIGHT={}" |
| 56 | face.default_weight |
| 57 | ); |
| 58 | |
| 59 |