// The three bundled faces — and the amendment they are.//// `Typography.swift`'s rule is that Cotton wears the SYSTEM face: ten roles,// zero loaded fonts. That rule still governs every sentence the app SETS —// rows, titles, captions, the editor. What these faces are for is the// thing that rule never covered: LETTERING ON AN OBJECT. Home's project caps// (`Paper/ProjectCaps.swift`) are photographs of enamelled bottle caps// with the project's name printed on them, and print on a cap has a face of// its own the way a label on a jar does. The owner's ruling of 2026-09-13,// with the reference picture: "the text has to look like this" — a condensed// serif italic on the caps, a heavier display serif over the grid. The todo// slips are the second object: photographs of paper// index cards with the todo TYPED on them, and typing has a face of its own.//// All are SIL Open Font License (the licences sit beside the files)://// * `InstrumentSerif-Italic` — the cap lettering. One style, on purpose:// the reference mixed three faces because a picture generator does; a// collection of caps from one bottler is set in one.// * `FrauncesTitle-SemiBold` — a PAGE's title: "Cotton", "Todos", "Notes".// A static instance (opsz 48, wght 580, no wonk) cut from the variable// font, because `Font.custom` cannot set a variation axis.// * `FrauncesText-Regular` — the same family at its TEXT optical size// (opsz 18, wght 450): section headings, an object's name on paper, a// person's name. The redesign's pictures set everything below the page// title in a book-weight serif; one high-contrast display cut at every// size was the largest gap between the built screens and the pictures.// Both are cut by `scripts/gen-fonts/cut_fraunces.py`.// * `CourierPrime-Regular` and `CourierPrime-Italic` — the typewriter on// the cards: the label in the upright, the day and the counts in the// italic. Two styles because a typed card has both; no bold, because a// typewriter has none.// * `Caveat-Regular` — the handwriting the paper kit added (`Paper/`). It is// the voice of ANNOTATION and nothing else: the date in a sheet's corner,// "6 days late", "3 of 12", "totals agree", "Saved". One style, because a// person writing in a margin does not change pens.// * `LibreCaslonText-Regular` — the book-weight Caslon the invitation's// pictures set its title in, now a file's, a passport's and a blank// jacket's title (`PersonFileFace`, `PassportFace`, `BookHardbackFace`). A static instance (wght 400) cut from the variable// font by `scripts/gen-fonts/cut_libre_caslon.py`.// * `MsMadi-Regular` — a signature's hand (a rolodex's foot, a slip's time,// a cassette's label). One style; it is a pen, not a family.// * `BarlowCondensed-ExtraBoldItalic` — a record sleeve's printed title and// artist where the album keeps no cover (`AlbumSleeveFace`): the heavy,// condensed, leaning sans the dark room's covers are set in. One style,// the static cut Google Fonts ships.// * `BarlowCondensed-SemiBold` — the letterboard's cream capitals: the// upright of the same family, set on a tool's fan tiles where the tool's// tile says `letterboard` (Cotton Cinemas, 6 Nov 2026). Its Latin alone,// cut by `scripts/gen-fonts/cut_barlow_condensed.py`.//// THEY ARE FIXED-SIZE. A cap is a photograph and its lettering scales with// the cap, not with Dynamic Type — a name that grew with the text size would// walk off the enamel, and a label that grew would walk off the card. So no// face here goes through `cottonType`, and nothing else in the app reaches// them: the caps and the cards are the two callers, and a third is a design// decision, not a call site's.//// REGISTERED FROM THE PACKAGE BUNDLE, not from `UIAppFonts`. The faces are// resources of `CottonUI` (`Package.swift`: `.copy("Resources/Fonts")`), and// `UIAppFonts` reads the APP bundle only — so they are registered once, with// CoreText, the first time a caller asks. The Mac has the same bundle, FOUND// BY PATH (`Resources.swift`), so the faces register there too; the system// faces — serif for the caps and the word, monospaced for the typewriter —// are the fallback for a Mac build that carries no bundle at all, not the// Mac's normal state.importCoreTextimportSwiftUIpublicenumCottonFonts {/// The cap lettering's PostScript name.publicstaticlet capFace = "InstrumentSerif-Italic"/// The page title's PostScript name.publicstaticlet displayFace = "FrauncesTitle-SemiBold"/// The typewriter's PostScript name — the label on a card.publicstaticlet typeFace = "CourierPrime-Regular"/// The typewriter's italic — the day on a card, the count on a section.publicstaticlet typeItalicFace = "CourierPrime-Italic"/// The handwriting's PostScript name — annotation on paper.publicstaticlet handFace = "Caveat-Regular"/// The serif at its text size — headings and names on paper.publicstaticlet textFace = "FrauncesText-Regular"/// The book-weight Caslon a name is set in (`PersonFileFace`, `BookHardbackFace`).publicstaticlet caslonFace = "LibreCaslonText-Regular"/// The signature hand (`RolodexFace`, `ThreadSlipsFace`, the cassette's label: `BareCassette`).publicstaticlet signatureFace = "MsMadi-Regular"/// The record sleeve's condensed heavy sans (`AlbumSleeveFace`).publicstaticlet sleeveFace = "BarlowCondensed-ExtraBoldItalic"/// The letterboard's upright condensed capitals (`PaintedTile`).publicstaticlet letterboardFace = "BarlowCondensed-SemiBold"/// Every bundled face, in the order they arrived; what the registration/// loop walks and what the resource guard checks.publicstaticlet faces = [capFace, displayFace, typeFace, typeItalicFace, handFace, textFace, caslonFace, signatureFace, sleeveFace, letterboardFace]/// A BUSINESS FLAVOUR'S FACES — worn only where a flavour's look names/// them (`FlavourLook`), never by Cotton's own theme. Montserrat (OFL,/// the licence beside the files) is Sharmila's Yoga Zone's: the regular/// for what is read, the semibold for what heads it. Static cuts, since/// `Font.custom` cannot set a variation axis. Not in `faces`: Cotton's own/// theme never names these.publicstaticlet brandRegularFace = "Montserrat-Regular"publicstaticlet brandHeadingFace = "Montserrat-SemiBold"publicstaticlet brandFaces = [brandRegularFace, brandHeadingFace]/// A bundled font file by name and extension, for a page that loads its/// own type (the book reader's EPUB sets Libre Caslon's `ttf` itself)./// Nil in a build with no resources.publicstaticfunc file(_ name: String, extension ext: String) -> URL? {CottonResources.bundle?.url(forResource: name, withExtension: ext, subdirectory: "Fonts") }/// A flavour's face by its PostScript name, at a size the caller decides;/// the system face at `fallback` weight where the file is not registered.publicstaticfunc brand(_ face: String, _ size: CGFloat, fallback: Font.Weight) -> Font { register() #if canImport(UIKit)return .custom(face, fixedSize: drawable(size)) #elsereturn brandFacesLoaded ? .custom(face, fixedSize: drawable(size)) : .system(size: drawable(size), weight: fallback) #endif }/// The lettering on a cap, at a size the CAP decides.publicstaticfunc cap(_ size: CGFloat) -> Font { register() #if canImport(UIKit)return .custom(capFace, fixedSize: drawable(size)) #elsereturn facesLoaded ? .custom(capFace, fixedSize: drawable(size)) : .system(size: size, design: .serif).italic() #endif }/// A page's title, at a size the page decides. Nothing below the title/// wears it — that is `serif(_:)`.publicstaticfunc display(_ size: CGFloat) -> Font { register() #if canImport(UIKit)return .custom(displayFace, fixedSize: drawable(size)) #elsereturn facesLoaded ? .custom(displayFace, fixedSize: drawable(size)) : .system(size: size, weight: .semibold, design: .serif) #endif }/// The serif at its text optical size — a section heading, an object's/// name, at a size the object decides.publicstaticfunc serif(_ size: CGFloat) -> Font { register() #if canImport(UIKit)return .custom(textFace, fixedSize: drawable(size)) #elsereturn facesLoaded ? .custom(textFace, fixedSize: drawable(size)) : .system(size: size, design: .serif) #endif }/// An invitation's title, at a size the card decides.publicstaticfunc caslon(_ size: CGFloat) -> Font { register() #if canImport(UIKit)return .custom(caslonFace, fixedSize: drawable(size)) #elsereturn facesLoaded ? .custom(caslonFace, fixedSize: drawable(size)) : .system(size: size, design: .serif) #endif }/// A place written as a signature, at a size the card decides.publicstaticfunc signature(_ size: CGFloat) -> Font { register() #if canImport(UIKit)return .custom(signatureFace, fixedSize: drawable(size)) #elsereturn facesLoaded ? .custom(signatureFace, fixedSize: drawable(size)) : .system(size: size, design: .serif).italic() #endif }/// A record sleeve's printed title, at a size the SLEEVE decides.publicstaticfunc sleeve(_ size: CGFloat) -> Font { register() #if canImport(UIKit)return .custom(sleeveFace, fixedSize: drawable(size)) #elsereturn facesLoaded ? .custom(sleeveFace, fixedSize: drawable(size)) : .system(size: size, weight: .heavy).width(.condensed).italic() #endif }/// A letterboard tile's capitals, at a size the TILE decides.publicstaticfunc letterboard(_ size: CGFloat) -> Font { register() #if canImport(UIKit)return .custom(letterboardFace, fixedSize: drawable(size)) #elsereturn facesLoaded ? .custom(letterboardFace, fixedSize: drawable(size)) : .system(size: size, weight: .semibold).width(.condensed) #endif }/// The typing on a card, at a size the CARD decides.publicstaticfunc type(_ size: CGFloat) -> Font { register() #if canImport(UIKit)return .custom(typeFace, fixedSize: drawable(size)) #elsereturn facesLoaded ? .custom(typeFace, fixedSize: drawable(size)) : .system(size: size, design: .monospaced) #endif }/// The typing's italic — the day on a card, the count on a section.publicstaticfunc typeItalic(_ size: CGFloat) -> Font { register() #if canImport(UIKit)return .custom(typeItalicFace, fixedSize: drawable(size)) #elsereturn facesLoaded ? .custom(typeItalicFace, fixedSize: drawable(size)) : .system(size: size, design: .monospaced).italic() #endif }/// A departures board's flap lettering, now a plain video sleeve's/// title (`FilmVHSFace`): the system sans at its compressed width and a/// semibold weight — tall, narrow capitals. A/// system face, so nothing is registered for it, and fixed-size as the/// faces above are: a letter that grew would walk off its flap.publicstaticfunc flap(_ size: CGFloat) -> Font { .system(size: drawable(size), weight: .semibold).width(.compressed) }/// The annotation written on a sheet, at a size the SHEET decides. Caveat/// runs small for its point size — its x-height is well under the/// typewriter's — so a caller asking for "the same size as the meta line"/// should ask for one or two points more./// An SF Symbol's glyph at `size` — the one door a face sizes a symbol/// through, so the size is a theme key and never a literal at the call.publicstaticfunc symbol(_ size: CGFloat, weight: Font.Weight = .regular) -> Font { .system(size: size, weight: weight) }publicstaticfunc hand(_ size: CGFloat) -> Font { register() #if canImport(UIKit)return .custom(handFace, fixedSize: drawable(size)) #elsereturn facesLoaded ? .custom(handFace, fixedSize: drawable(size)) : .system(size: size, design: .serif).italic() #endif }/// Once. CoreText refuses a second registration of the same file with an/// error this ignores on purpose: "already registered" is the state it/// wanted.////// The bundle is `CottonResources.bundle` — `Bundle.module` on the phone,/// and on the Mac the same bundle FOUND BY PATH (`Resources.swift`), where/// `.copy("Resources/Fonts")` has put the files as-is. A Mac build with no/// bundle registers nothing and the accessors keep their system fallbacks.privatestaticlet registration: Bool = {guardlet bundle = CottonResources.bundle else { returnfalse }var registered = 0for face in faces {guardlet url = bundle.url(forResource: face, withExtension: "ttf", subdirectory: "Fonts") else {continue } _ = CTFontManagerRegisterFontsForURL(url as CFURL, .process, nil) registered += 1 }return registered == faces.count }()/// The flavours' faces, registered the same way and counted apart, so a/// build without them still has every house face.privatestaticlet brandRegistration: Bool = {guardlet bundle = CottonResources.bundle else { returnfalse }var registered = 0for face in brandFaces {guardlet url = bundle.url(forResource: face, withExtension: "ttf", subdirectory: "Fonts") else { continue } _ = CTFontManagerRegisterFontsForURL(url as CFURL, .process, nil) registered += 1 }return registered == brandFaces.count }()staticfunc register() { _ = registration _ = brandRegistration }/// A face sized from a layout's geometry is asked for at 0 pt on the/// first pass, and a 0 pt font cannot be archived: a renderer refused the/// whole view ("invalidFont") and a gallery preview of the caps, the tools/// or the chats drew blank (5 Oct 2026). Never/// smaller than a point.staticfunc drawable(_ size: CGFloat) -> CGFloat { size.isFinite ? max(size, 1) : 1 }/// Every face is registered — on the Mac, the difference between the/// typewriter and a system monospaced stand-in.staticvar facesLoaded: Bool { registration }/// Every flavour face is registered.staticvar brandFacesLoaded: Bool { brandRegistration }}