editor: Set the font through its options (#2794)
Closes #2787.
`Input` gave a code editor a rem-relative line height — `Rems(1.25)`,
which resolves to 20px whatever the font size is — so `.text_sm()`
shrank the glyphs and left the leading behind, and a larger font
overlapped its own rows. The editor also inherited a proportional family
rather than the theme's monospace one, so every application had to pin
one itself.
Both are now defaults the editor sets before refining its own style over
them:
```rust
Editor::new(&editor).text_sm()
Editor::new(&editor)
.font_family("JetBrains Mono")
.text_size(px(15.))
```
No new API: these are the ordinary `Styled` methods every element has,
so `font_weight` and `line_height` work the same way. The element paints
with the ambient text style, so what the editor's own style says is what
reaches the glyphs, the gutter, and the rows together.
`gpui-base` is untouched. Its editor is unstyled by design, and the
element the application wraps it in already carries the font.
## Breaking Changes
`Editor` now uses the theme's monospace font by default, so applications
no longer have to pin one themselves:
```diff
Editor::new(&self.editor_state)
- .font_family(cx.theme().mono_font_family.clone())
- .text_size(cx.theme().mono_font_size)
.readonly(self.readonly)
```
An editor that was inheriting a sans-serif ambient font will now render
monospace, and one that was relying on the fixed 20px rows will now get
rows proportional to its font size. Existing `.font_family()` /
`.text_size()` calls keep working and still win over the default.
## Tests
`gpui-component` asserts the laid-out row height: the theme default is
20px (13px × 1.5), and `.text_size(px(24.))` and `.text_size(px(40.))`
carry the rows to 36px and 60px with them.
## Story
The Editor story drops the manual monospace setup, and its settings move
into one `Options` menu like the other stories have: read-only, font
family (the theme's own, plus Menlo, Consolas, and Monaco), and font
size (11 / 13 / 16 / 20px).
## Docs
Font sections added to `website/docs/components/editor.md`,
`website/zh-CN/docs/components/editor.md`, and
`website/base/primitives/editor.md`.
---
AI-generated with Claude Code; reviewed and verified by the author.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> J
Jason Lee committed
14359a0cdd00657eb68fa946bfd99cd83c26e002
Parent: 1a27414
Committed by GitHub <noreply@github.com>
on 8/21/2026, 8:15:16 AM