// The typed name card — a person with no photograph, and the thread with no// picture.//// It is the same object as an instant print without the print: a square of cream// paper with the name TYPED on it. The reference grid (`07-people-grid`) is what// settles the face — the names on those squares are struck by a typewriter, not// set in a serif — and it is also what makes the card work: a grid of prints with// gaps in it reads as missing data, and a grid of prints and typed cards reads as// a person who has not sent a photograph.//// `detail` is the second line, in pencil: a phone's last four, a thread's count,// whatever the screen has. Nothing when the screen has none.//// A MONOGRAM — a chat's initial, a group's two letters — is struck large, at// the theme's `monogram_size` of the side, and only when the caller says the// card carries one. A short name is still a name: "Jo" is typed at a name's// size, never guessed into a monogram by its letter count.importSwiftUIpublicstructTypedCard: View { @Environment(\.theme) privatevar themeprivatelet name: Stringprivatelet detail: String?/// Red for a birthday's words; nil keeps the meta line's own ink.privatelet detailInk: PaperInk?privatelet seed: Stringprivatelet dye: PaperDye/// `false` for a card laid square among square prints, where nothing/// tilts.privatelet tilts: Bool/// Whether `name` is a monogram (a chat's initial, a group's letters)/// rather than a name.privatelet monogram: Boolpublicinit( name: String, detail: String? = nil, detailInk: PaperInk? = nil, seed: String, dye: PaperDye = .cream, tilts: Bool = true, monogram: Bool = false ) {self.name = nameself.monogram = monogramself.detail = detailself.detailInk = detailInkself.seed = seedself.dye = dyeself.tilts = tilts }/// Every number a fraction of the card's own side, read from a theme.structPrint {let scale: ThemeScalevar nameFraction: CGFloat { TypedCardKnobs.typedCardNameSize }var nameMin: CGFloat { TypedCardKnobs.typedCardNameMin }var nameMax: CGFloat { TypedCardKnobs.typedCardNameMax }var detailSize: CGFloat { TypedCardKnobs.typedCardDetailSize }var detailMin: CGFloat { TypedCardKnobs.typedCardDetailMin }var detailMax: CGFloat { TypedCardKnobs.typedCardDetailMax }var gap: CGFloat { TypedCardKnobs.typedCardGap }/// A MONOGRAM is struck at the theme's share of the side: at a name's/// size it would be a speck on a 44pt card.var monogramSize: CGFloat { scale[.monogramSize] }var monogramMin: CGFloat { TypedCardKnobs.typedCardMonogramMin }/// How far a name may shrink to fit — the card's floor on every screen.var smallestScale: CGFloat { TypedCardKnobs.typedCardSmallestScale }/// The step the name's tried sizes fall by — a tenth.var scaleStep: CGFloat { TypedCardKnobs.typedCardNameScaleStep }/// A birthday's handwritten words against the typed detail size.var handDetailScale: CGFloat { TypedCardKnobs.typedCardHandDetailScale }var nameLines: Int { TypedCardKnobs.typedCardNameLines }/// The size the name — or the monogram — is struck at on a card/// `side` points wide.func nameSize(side: CGFloat, monogram: Bool) -> CGFloat {if monogram { return max(monogramMin, side * monogramSize) }return min(nameMax, max(nameMin, side * nameFraction)) }/// The sizes a name is tried at, largest first: the card's own size/// down to its floor, in steps of a tenth, and never under the/// theme's caption size — a name two lines do not hold there is cut/// by its lines, not shrunk further (architect, 16 Oct 2026).func nameSizes(side: CGFloat, monogram: Bool) -> [CGFloat] {let caption = scale[.typeCaptionSize]let full = max(caption, nameSize(side: side, monogram: monogram))let steps = stride(from: CGFloat(1), to: smallestScale, by: -scaleStep).map { full * $0 }var sizes: [CGFloat] = []for size in (steps + [full * smallestScale]).map({ max(caption, $0) }) where sizes.last != size { sizes.append(size) }return sizes } }/// The size the name is struck at on a card `side` points wide, in the/// caller's worn theme — for the prints outside the kit that strike a name/// the card's way.staticfunc nameSize(side: CGFloat, in scale: ThemeScale, monogram: Bool) -> CGFloat {Print(scale: scale).nameSize(side: side, monogram: monogram) }publicvar body: someView {let typed = Print(scale: theme.scale)GeometryReader { geo inlet side = geo.size.widthPaper(dye: dye, edge: .torn, seed: seed, tilt: tilts, fills: true) { VStack(spacing: side * typed.gap) { typedName(side: side, print: typed)iflet detail {let size = min(typed.detailMax, max(typed.detailMin, side * typed.detailSize))// A birthday's words are written by hand in red// pencil; the time stays typed.Group {iflet detailInk {Text(detail).paperHand(size * typed.handDetailScale, ink: detailInk) } else {Text(detail).paperMeta(size) } } .lineLimit(1) } } .frame(maxWidth: .infinity, maxHeight: .infinity) } } .aspectRatio(1, contentMode: .fit) .accessibilityElement(children: .combine) }/// The name, struck as a tile's words are (`InkFit.wholeWords`): at the/// largest of its sizes where it stands whole in its two lines, never/// broken inside a word — a word wider than the card's line even at the/// floor is set smaller still, on a line of its own. A Text left to itself/// keeps the size and splits the word ("Download / s" on the fan's/// Downloads tile, 362 walk, 6 Nov 2026), so the size is measured here and/// the break given where a Text would cut (`InkFit.broken`).privatefunc typedName(side: CGFloat, print typed: Print) -> someView {let set = typed.name(name, side: side, face: theme.type.body, monogram: monogram)returnText(set.words) .paperBody(set.size) .multilineTextAlignment(.center) .lineLimit(typed.nameLines) .frame(maxWidth: .infinity) }}extensionTypedCard.Print {/// The width a name is typed in on a card `side` points wide: the/// paper's own margins off it (`Paper`'s inset).func line(side: CGFloat) -> CGFloat { max(0, side - 2 * scale.inset(forWidth: side)) }/// The size a name is struck at on a card `side` points wide, and the/// words as the Text is given them: whole words, at most two lines.func name(_ name: String, side: CGFloat, face: ThemeFace, monogram: Bool) -> (size: CGFloat, words: String) {let width = line(side: side)let size = InkFit.wholeWords(name, face: face, sizes: nameSizes(side: side, monogram: monogram), width: width, lines: nameLines)return (size, InkFit.broken(name, face: face, size: size, width: width)) }}/// The sizes, counts and timings TypedCard draws with: Swift's own, beside/// their reader — a theme sets only its tokens (`scale.tokens`).enumTypedCardKnobs {staticlet typedCardDetailMax: CGFloat = 13staticlet typedCardDetailMin: CGFloat = 9staticlet typedCardDetailSize: CGFloat = 0.085staticlet typedCardGap: CGFloat = 0.035staticlet typedCardHandDetailScale: CGFloat = 1.15staticlet typedCardMonogramMin: CGFloat = 13staticlet typedCardNameLines = 2staticlet typedCardNameMax: CGFloat = 17staticlet typedCardNameMin: CGFloat = 11staticlet typedCardNameScaleStep: CGFloat = 0.1staticlet typedCardNameSize: CGFloat = 0.115staticlet typedCardSmallestScale: CGFloat = 0.55}