Skip to content

feat: typography controls — lineHeight, fontThicken - #62

Merged
griffinwork40 merged 1 commit into
mainfrom
afk/typography-controls
Aug 25, 2026
Merged

feat: typography controls — lineHeight, fontThicken#62
griffinwork40 merged 1 commit into
mainfrom
afk/typography-controls

Conversation

@griffinwork40

Copy link
Copy Markdown
Owner

Typography controls: lineHeight + fontThicken

Adds two user-configurable typography fields and extracts the font-sizing
methods into a dedicated extension file.

What ships

fontThicken (bool, default false)

Applies CGContextSetFontSmoothingStyle(48) — medium sub-pixel dilation —
before SwiftTerm's glyph draw pass. This is the same style Terminal.app uses
(and iTerm2, MacVim, Emacs). It compensates for the AA bleed direction on
white-on-dark rendering that makes terminal text appear thinner than the same
font on a light background.

  • Call is confined to UmberTerminalView.draw(_:) so the CGContext is
    always the one live for the current draw call.
  • Guarded by the user preference: when false, the override is a zero-cost
    pass-through to super.draw(dirtyRect).
  • Private API, same as Terminal.app/iTerm2/Emacs — linker surfaces a
    missing-symbol error at build time if Apple removes it (no silent runtime trap).
  • Vendor note: MacTerminalView.swift:954 already declares open override func draw,
    so no vendor patch is needed.

lineHeight (CGFloat 0.8–2.0, default 1.0)

Multiplier on the font's natural line metrics, wired to SwiftTerm's public
lineSpacing property. 1.2 = 20% extra leading. The setter internally
calls resetFont()computeFontDimensions()processSizeChange, which
correctly resizes the terminal grid — no partial relayout or clipped rows.

applyTypography(_:) is called from apply(config:) after setFontSize
because lineSpacing needs the font already installed on the view.

Extraction: TerminalPane+Typography.swift (new file)

TerminalPane.swift was at 346/350 LOC. The font-sizing block (constants,
setFontSize, adjustFontSize, resetFontSize, currentFontSize) moved to
TerminalPane+Typography.swift alongside the new applyTypography(_:).

Access fix: config and fontSize were private (file-scoped in Swift).
Changed to internal (default, no keyword) so the cross-file extension can
reach them. A comment in the source explains why — Swift private is
file-scoped, not class-scoped, unlike many other languages.

What does NOT ship (deferred)

  • Ligature control: SwiftTerm's attribute cache (attributes, urlAttributes)
    is a private var on TerminalView with no public setter. Disabling ligatures
    would require a vendored patch to getAttributes(_:withUrl:). Omitted rather
    than half-implemented; documented in TerminalPane+Typography.swift header.

File sizes

All files ≤ 350 LOC. TerminalPane.swift went from 346 → 317 lines.

Checklist

  • swift build passes (zero errors, pre-existing warnings only)
  • bash Scripts/check-file-size.sh — all 117 files within ceiling
  • fontThicken and lineHeight documented in StarterConfig.swift with usage notes
  • All @MainActor, no try!
  • Vendor draw(_:) is already open — no patch required

@griffinwork40
griffinwork40 force-pushed the afk/typography-controls branch from 278841b to 87e1fb4 Compare August 25, 2026 20:11
Config fields:
- fontThicken: bool — applies CGContextSetFontSmoothingStyle(48) before
  SwiftTerm glyph draw, the same medium dilation Terminal.app uses.
  Confined to UmberTerminalView.draw(_:) so the context is always
  the right one for the in-flight draw call.
- lineHeight: CGFloat 0.8–2.0 — multiplier on font natural metrics,
  wired to SwiftTerm's public lineSpacing property which correctly
  resizes the terminal grid after changing (no partial relayout).

Extraction: font-sizing methods moved from TerminalPane.swift (was
346/350 LOC) into new TerminalPane+Typography.swift. Access fix:
config and fontSize were private (file-scoped); changed to internal so
the cross-file extension can read/write them. The comment explains why
(Swift private = file-scoped, not class-scoped).

applyTypography(_:) is called from apply(config:) AFTER setFontSize
because lineSpacing internally calls resetFont() → computeFontDimensions()
→ processSizeChange, all of which require the font to be installed first.

Vendor draw(_:) status: MacTerminalView.swift:954 declares
'open override func draw(_ dirtyRect:)' — the override in UmberTerminalView
is valid and the build confirms it. No vendor patch needed.

StarterConfig.swift: added fontThicken and lineHeight commented entries
with usage docs matching the config fields.

All files ≤ 350 LOC (TerminalPane.swift: 317).
@griffinwork40
griffinwork40 force-pushed the afk/typography-controls branch from 87e1fb4 to 6e7f229 Compare August 25, 2026 20:14
@griffinwork40
griffinwork40 merged commit ef42ab7 into main Aug 25, 2026
@griffinwork40
griffinwork40 deleted the afk/typography-controls branch August 25, 2026 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant