zed/crates/component_preview
Sergei G. f9d57b54dc
component_preview: Fix example rendering no text or icons (#59241)
`cargo run -p component_preview --example component_preview` does not
work.
On current main it panics at startup:

```
thread 'main' panicked at crates/gpui/src/action.rs:296:13:
Action with name `zed::Quit` already registered
```

With that panic fixed, the window opens but renders no text and no icons
(see Showcase below).s

## Solution

Root cause for the blank window: `component_preview` package resolves
`gpui_platform` with just `"screen-capture"`.

On macOS the missing `font-kit` feature makes `MacPlatform` fall back to
`gpui::NoopTextSystem`, as mentiond also in README (or CONTRIBUTE) file.

On Linux the missing `wayland`/`x11` features leave no windowing backend
at all.

list of changes:

- Enable the same `gpui_platform` features as the `zed` binary.
- Attach `Assets` and load the embedded fonts.
- Initialize `env_logger` so platform warnings reach the terminal.
- Fix three startup panics: move the example's `Quit` action to the
`component_preview` namespace.

## Testing

Tested on macOS/Linux, not tested on Windows. I use Parallel VMs.

## Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)

## Showcase

Before:
<img width="1312" height="945" alt="cp_pr1_before"
src="https://github.com/user-attachments/assets/4611596f-6775-4863-bd4a-5f4d8c642e35"
/>

After:
<img width="1312" height="945" alt="cp_pr1_after"
src="https://github.com/user-attachments/assets/8f8082e6-c8cd-48f5-946a-032ce8186d30"
/>

---

Release Notes:

- N/A
2026-06-15 03:26:51 +00:00
..
examples component_preview: Fix example rendering no text or icons (#59241) 2026-06-15 03:26:51 +00:00
src gpui: Allow chaining flex_grow() and flex_shrink() with custom factors (#58142) 2026-06-01 04:40:13 +00:00
Cargo.toml component_preview: Fix example rendering no text or icons (#59241) 2026-06-15 03:26:51 +00:00
LICENSE-GPL component_preview: Fix license symlink (#46379) 2026-01-08 17:12:54 +00:00