feat(reading): polish typography, externalize CSS

Critique-directed polish of the reading surface (#72 ruling: pipeline
calm, surface not-calm) plus the single-user typography rework:

- Flow: leading 1.5, paragraph gap tightened; heading ladder rescaled
  (h1 1.15x / h2 0.85x / h3 body-face semibold) with cling margins,
  hN+hN suppression, no title dead space
- Constructs: confident blockquote (near-ink text, 3px rail, nesting
  degrades), booktabs tables, tinted code panels, relative inline code
- Fonts hardcoded for Alexander's faces: Valkyrie OT B 17 body,
  Concourse OT Semibold headings, UbuntuMono 14 code; 66ch measure
- Stylesheet moved to Museion/Resources/reading.css, read fresh per
  page build — Debug builds load the repo copy (#filePath), so CSS
  edits hot-reload on the next reading toggle
- Settings Typography/Text Flow sections and all flow-key plumbing
  deleted (56 insertions, 417 deletions)

Refs #72, #78. Detector: 192 findings -> 0. Build + 93 tests green.

[Generated by AI]
This commit is contained in:
AlexKucera committed 2026-10-07 17:02:10 +02:00
1 parent eae86dd2ef
commit 4cb753d17f
9 files changed
+134 -417

No files matched your search

+22 -63
View File
@@ -166,6 +166,28 @@ nonisolated enum ReadingPresenter {
// MARK: Page assembly
/// The reading stylesheet, read fresh per page build (#72 rework): the
/// CSS lives in Resources/reading.css so the look is editable while the
/// app runs — save the file, toggle reading (⌘R), see it. ~3 KB read =
/// microseconds against the ~20 ms apex spawn next to it.
/// Debug builds prefer the REPO copy (`#filePath` points into the
/// checkout) so CSS edits apply with no rebuild; release builds ship the
/// bundled copy (`#filePath` is stripped in release, so this resolves to
/// the bundle without any config).
static func styleSheet() -> String {
#if DEBUG
let repoCSS = URL(fileURLWithPath: #filePath) // …/Museion/ReadingPresenter.swift
.deletingLastPathComponent()
.appendingPathComponent("Resources/reading.css")
if let live = try? String(contentsOf: repoCSS, encoding: .utf8), !live.isEmpty {
return live
}
#endif
return Bundle.main.path(forResource: "reading", ofType: "css").flatMap {
try? String(contentsOf: URL(fileURLWithPath: $0), encoding: .utf8)
} ?? ""
}
/// Render `text` to a full page: chunk-sentinels → apex → attribute
/// restamp → style-injected shell. `postFolder` resolves relative images
/// (nil = drafts: relative paths stay raw, missing images fail soft).
@@ -193,67 +215,4 @@ nonisolated enum ReadingPresenter {
.replacingOccurrences(of: "<", with: "&lt;")
.replacingOccurrences(of: ">", with: "&gt;")
}
// MARK: Stylesheet — ProseTypography slots + flow knobs as CSS variables
/// Variables from the live slot values (UserDefaults-driven, #70/#71) +
/// the spike's fixed rules (proven live, #74). `familyName` (not the
/// member PS name) is what CSS font matching wants; weight rides CSS.
static func styleSheet() -> String {
func family(_ font: NSFont) -> String {
"\"\(font.familyName ?? (font.displayName ?? ""))\""
}
func px(_ value: Double) -> String {
"\(String(format: "%.0f", value))px"
}
let body = ProseTypography.bodyFont
let head = ProseTypography.headingFont
let code = ProseTypography.codeFont
let line = ProseTypography.linePoints
return """
:root {
--body-face: \(family(body)), Georgia, serif;
--body-size: \(px(body.pointSize));
--headings-face: \(family(head)), Georgia, serif;
--headings-size: \(px(head.pointSize));
--code-face: \(family(code)), UbuntuMonoNFM, monospace;
--code-size: \(px(code.pointSize));
--lh: \(String(format: "%.2f", ProseTypography.lineHeightMultiple));
--para-space: \(px(Double(line * ProseTypography.paragraphSpacingLines)));
--head-space: \(px(Double(line * ProseTypography.headingSpacingLines)));
--measure: 640px;
--ink: #1d1d1f; --muted: #6e6e73; --hairline: #d2d2d7;
}
html { background: #fbfbfd; }
body {
margin: 24px auto; padding: 0 24px; width: var(--measure); max-width: calc(100vw - 48px);
color: var(--ink); font-family: var(--body-face); font-size: var(--body-size);
line-height: var(--lh); -webkit-font-smoothing: antialiased;
}
p { margin: var(--para-space) 0 0; }
h1, h2, h3, h4, h5, h6 { font-family: var(--headings-face); font-weight: 700; line-height: 1.15; margin: var(--head-space) 0 0; }
h1 { font-size: var(--headings-size); }
h2 { font-size: calc(var(--headings-size) * 0.77); }
h3 { font-size: calc(var(--body-size) + 1px); }
h4, h5, h6 { font-family: var(--body-face); font-size: var(--body-size); font-weight: 700; }
ul, ol { margin: var(--para-space) 0 0; padding-left: 1.6em; }
li { margin: 0; }
li > ul, li > ol { margin: 0; }
pre { font-family: var(--code-face); font-size: var(--code-size); margin: var(--para-space) 0 0;
padding: 8px 12px; border: 1px solid var(--hairline); border-radius: 6px; white-space: pre-wrap; }
code { font-family: var(--code-face); font-size: var(--code-size); }
blockquote { margin: var(--para-space) 0 0; padding-left: 14px; border-left: 1.5px solid var(--hairline); color: var(--muted); }
blockquote p { margin: 0; }
hr { border: none; border-top: 1px solid var(--hairline); margin: var(--head-space) 0 0; }
a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--hairline); text-underline-offset: 3px; }
table { border-collapse: collapse; margin: var(--para-space) 0 0; }
th, td { border: 1px solid var(--hairline); padding: 4px 10px; text-align: left; }
figure { margin: var(--para-space) 0 0; }
figure img { max-height: 1.6em; transition: max-height .25s ease; vertical-align: middle; }
figure:hover img { max-height: 420px; }
figcaption { display: none; }
section.footnotes { color: var(--muted); }
[data-source-line]:hover { background: rgba(0,122,255,.05); }
"""
}
}