// What the object faces share in setting words on a painted thing (an open// book's tag, a video's sticker): a line typed with its baseline where the// object puts it, a day as it is written on one, and a place's label read as// its kind's when the face's id is not its kind's.importCottonPaperimportCottonValuesimportSwiftUI/// A day as it is written on an object: the core's day words without the/// weekday they open with ("Mon 12 Oct" — "12 Oct"; "Mon 27 Oct 2025" —/// "27 Oct 2025"), and as a stamp strikes it, in capitals ("12 OCT").publicenumDayStamp {publicstaticfunc bare(_ day: String) -> String {let words = day.split(separator: " ")let kept = words.count > 1 && words[0].allSatisfy(\.isLetter) && words[1].allSatisfy(\.isNumber) ? words.dropFirst() : words[...]return kept.joined(separator: " ") }publicstaticfunc of(_ day: String) -> String { bare(day).uppercased() }}extensionDeckCard {/// The label over a place as the card's own words or its kind's line/// (`FactLabel`), for a face whose id is not its kind's.func label(_ slot: String, kind: String) -> String? {ifcase .object(let own)? = fields["labels"], let said = own[slot]?.text, !said.isEmpty { return said }returnFactLabel.of(kind, slot) }}/// Words set on a painted object.enumObjectWriting {/// `words` drawn with their baseline at `at`, from its x, in `font` and/// `ink`; squeezed to `width` when `fits` and it is wider, else drawn whole.staticfunc type(_ context: inoutGraphicsContext, _ words: String, font: Font, ink: Color, at: CGPoint, width: CGFloat, fits: Bool = false) {let text = context.resolve(Text(words).font(font).foregroundStyle(ink))let far = CGSize(width: 10_000, height: 10_000)let ideal = text.measure(in: far)let base = text.firstBaseline(in: far)let scale = fits && ideal.width > width ? width / ideal.width : 1var inner = context inner.translateBy(x: at.x, y: at.y) inner.scaleBy(x: scale, y: scale) inner.draw(text, at: CGPoint(x: 0, y: -base), anchor: .topLeading) }}