// The five voices. Text on paper uses these and nothing else.//// `Typography.swift`'s ten roles still govern every sentence the app SETS in// chrome — a settings row, a dialog, the keyboard. These five govern what is// PRINTED ON AN OBJECT, and the difference is material rather than taste://// title serif Fraunces Text the object's own name// body typewriter Courier Prime the record's content// meta typewriter Courier Prime a detail line, in pencil// hand handwriting Caveat annotation — dates, counts, states// red typewriter Courier Prime an exception, in the palette's red//// Each is a `ViewModifier` that sets a face, an ink and the one blend, so a// screen cannot set half of a voice. They are FIXED-SIZE for the reason the// faces are (`Fonts.swift`): print on an object scales with the object, never// with Dynamic Type, or a long name walks off the paper.importSwiftUI/// One voice. The face, the ink and the blend come off the theme: on paper/// the serif, the typewriter and the hand multiplied into the fibre; in a/// flat family the system face printed plainly.structPaperVoice: ViewModifier {publicenumFace: String, CaseIterable, Sendable {case serif, typewriter, typewriterItalic, handwriting }/// The size a caller left out — the theme's own for the voice.enumSize {case title, body, meta, hand }let face: Facelet size: CGFloat?let fallback: Sizelet ink: PaperInk @Environment(\.theme) privatevar themepublicfunc body(content: Content) -> someView { content .font(PaperVoice.font(face, size ?? points(fallback), theme: theme)) .foregroundStyle(theme.print(ink)) .blendMode(theme.printBlend) }privatefunc points(_ size: Size) -> CGFloat {switch size {case .title: return theme.scale.titleSizecase .body: return theme.scale.bodySizecase .meta: return theme.scale.metaSizecase .hand: return theme.scale.handSize } }staticfunc font(_ face: Face, _ size: CGFloat, theme: Theme) -> Font {switch face {case .serif: return theme.type.title(size)case .typewriter: return theme.type.body(size)case .typewriterItalic: return theme.type.meta(size)case .handwriting: return theme.type.hand(size) } }}extensionView {/// The object's own name, in the serif.publicfunc paperTitle(_ size: CGFloat? = nil, ink: PaperInk = .ink) -> someView { modifier(PaperVoice(face: .serif, size: size, fallback: .title, ink: ink)) }/// The record's content, typed.publicfunc paperBody(_ size: CGFloat? = nil, ink: PaperInk = .ink) -> someView { modifier(PaperVoice(face: .typewriter, size: size, fallback: .body, ink: ink)) }/// A detail line — typed, in pencil.publicfunc paperMeta(_ size: CGFloat? = nil, ink: PaperInk = .pencil) -> someView { modifier(PaperVoice(face: .typewriterItalic, size: size, fallback: .meta, ink: ink)) }/// An annotation, handwritten. The date in a corner, "6 days late", a count.publicfunc paperHand(_ size: CGFloat? = nil, ink: PaperInk = .pencil) -> someView { modifier(PaperVoice(face: .handwriting, size: size, fallback: .hand, ink: ink)) }/// An exception, typed in red ink.publicfunc paperRed(_ size: CGFloat? = nil) -> someView { modifier(PaperVoice(face: .typewriter, size: size, fallback: .body, ink: .red)) }}