Skip to content

Let apps set fonts, weights, letter spacing and line height - #20

Merged
servercimen merged 1 commit into
feature/style-colorsfrom
feature/style-fonts
Nov 20, 2026
Merged

servercimen merged 1 commit into
feature/style-colorsfrom
feature/style-fonts

Conversation

@servercimen

@servercimen servercimen commented Nov 20, 2026 •

Copy link
Copy Markdown
Owner

Summary

TranscriptStyle could set only the body size and spacing: system fonts, headings at fixed multiples, and no Dynamic Type.

  • TranscriptFont: a font name or the system font, a size, a weight, a monospaced option, letter spacing and a line height.
  • TranscriptStyle.bodyFont, headingFonts (one per level; later levels use the last) and codeFont (also the design of inline code, at 0.9 times the text around it). Nil or empty keeps the fonts that were used before.
  • A line height replaces lineSpacing for that kind of text, centres the text in the line, and is never less than the font needs.
  • TranscriptStyle.scaled(for:) scales every text size and line height as UIFontMetrics scales body text. TranscriptText applies it from the environment when scalesWithDynamicType is on.
  • The README's Styling section describes it.

Closes #2.

Stack

This PR is part of a stack. It is based on #19 (feature/style-colors), so its diff shows only this change. Merge the stack in order, starting with #17.

Tests

  • Seven new unit tests: a named font, the system font's weight, heading levels past the end, the inline code font, letter spacing, line heights, and a line height below the font's own. swift test: 131 tests pass.
  • The unit tests run on macOS, so they use the NSFont path. The iOS path was checked on an iPhone 12 mini, iOS 27.0:
    • A body font with a 50 pt line height gives a 50 pt line, and Courier at 30 pt a 30 pt line.
    • With scalesWithDynamicType, the same text is 22 pt tall at .large and 48 pt at .accessibility3.

🤖 Generated with Claude Code

TranscriptStyle could set only the body size and spacing. The text always
used system fonts, headings used fixed multiples of the body size, and the
text did not follow Dynamic Type, so an app with its own type scale could
not make the text match the rest of its UI.

TranscriptFont describes one kind of text: a font name or the system font,
a size, a weight, a monospaced option, letter spacing and a line height.
TranscriptStyle has bodyFont, headingFonts (one per level) and codeFont,
which inline code also uses. Nil or empty keeps the fonts that were used
before. A line height replaces lineSpacing for that kind of text, centres
the text in the line, and is never less than the font needs.

scaled(for:) scales every text size and line height for a content size
category, as UIFontMetrics scales body text. TranscriptText applies it
from the environment when scalesWithDynamicType is on.

Closes #2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

Let apps set fonts, weights, letter spacing and line height

1 participant