component_preview: Fix example rendering no text or icons#59241
Open
grishy wants to merge 1 commit into
Open
Conversation
The example never attached the embedded asset source and built gpui_platform without any platform text-system features. On macOS the missing "font-kit" feature makes MacPlatform fall back to gpui::NoopTextSystem, which accepts fonts and resolves font ids but rasterizes every glyph to an empty bitmap, so the window rendered no text at all. On Linux the missing "wayland"/"x11" features leave no windowing backend either. Icons were missing because the SVG assets were never embedded. Attach Assets and load the embedded fonts (the default ".ZedSans" UI font resolves to the bundled IBM Plex Sans, which is not a system font), and enable the same gpui_platform features as the zed binary. Initialize env_logger so platform warnings reach the terminal. Also fix three startup panics: - zed::Quit is already registered by zed_actions (linked through the workspace crate), so the example's own Quit action moves to the component_preview namespace. - db::kvp::KeyValueStore::global panics unless the app database global is set first. - ui_input::InputField panics unless the editor factory registered by editor::init exists.
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
cargo run -p component_preview --example component_previewdoes not work.On current main it panics at startup:
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_previewpackage resolvesgpui_platformwith just"screen-capture".On macOS the missing
font-kitfeature makesMacPlatformfall back togpui::NoopTextSystem, as mentiond also in README (or CONTRIBUTE) file.On Linux the missing
wayland/x11features leave no windowing backend at all.list of changes:
gpui_platformfeatures as thezedbinary.Assetsand load the embedded fonts.env_loggerso platform warnings reach the terminal.Quitaction to thecomponent_previewnamespace.Testing
Tested on macOS/Linux, not tested on Windows. I use Parallel VMs.
Self-Review Checklist:
Showcase
Before:

After:

Release Notes: