Files
Drew DibbleandClaude Opus 5.5 317ca00ccc UI: an embedder of the egui panels binds their font families without shipping their faces
The panels and dialogs draw in their own egui families (`ui`,
`ui-semibold`, `mono`), and egui panics drawing text in a family no
font is bound to. Only `theme::install_fonts` binds them, and only
`VectorcraftApp::logic` calls it, on its first frame. An embedder that
draws the panels or dialogs itself (`dialogs::show`, a panel's `ui`)
on its own context, without `logic`, panics on the first semibold
title it draws, an effect dialog's for one. Calling `install_fonts`
avoids that, but it embeds the interface's five faces (about 2 MB)
whatever the embedder wants: today such an embedder keeps them out of
its binary only by never calling it, so that the linker drops them.

vectorcraft-ui-egui gets an `interface-fonts` feature, on by default,
that embeds those faces. Without it `install_fonts` binds the same
three families to egui's built-in fonts, so an embedder can always
call it. Those lack some symbols the panels show (→ ▾ ● ✓), which the
docs say. With the feature, `install_fonts` installs exactly what it
did before: the same font data and the same family stacks.

`tests/install_fonts.rs` draws an effect dialog on a context only
`install_fonts` prepared, and checks the face at the head of each
family in both configurations. `cargo xtask ci`'s `no-bundled-fonts`
step runs it without default features and lints the crate that way.
Without the `install_fonts` call, or without the semibold binding,
both tests fail with egui's "FontFamily::Name(\"ui-semibold\") is not
bound to any fonts". The two lib tests about the interface faces are
adjusted: the graphics-loss test checks a family install_fonts binds,
and the catalogs' glyph coverage test needs `interface-fonts`.
docs/development.md says when an embedder calls `install_fonts`, and
that it replaces the context's font definitions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 10:46:06 +07:00

70 lines
2.7 KiB
TOML

[package]
name = "vectorcraft-ui-egui"
version.workspace = true
edition.workspace = true
license.workspace = true
description = "VectorCraft egui frontend (menus, panels, tools and canvas); swappable — nothing below depends on it"
[lints]
workspace = true
[features]
default = ["bundled-fonts", "interface-fonts"]
# The fonts vectorcraft-text bundles for documents, through the engine's `bundled-fonts`. Off, for
# an embedder that supplies every document font at run time (`vectorcraft_text::FontDb::add_font`);
# the interface's own faces are `interface-fonts`.
bundled-fonts = ["vectorcraft-engine/bundled-fonts"]
# The interface's own faces (theme.rs: Inter, Source Sans 3, JetBrains Mono, about 2 MB). Off, the
# panels and dialogs draw in egui's built-in fonts, which lack some symbols they show (→ ▾ ● ✓);
# `theme::install_fonts` binds their families either way.
interface-fonts = []
[dependencies]
craft-ui = { workspace = true }
vectorcraft-geom = { workspace = true }
vectorcraft-color = { workspace = true }
vectorcraft-doc = { workspace = true }
vectorcraft-brush = { workspace = true }
vectorcraft-render = { workspace = true }
vectorcraft-text = { workspace = true }
vectorcraft-tools = { workspace = true }
vectorcraft-engine = { workspace = true }
vectorcraft-svg = { workspace = true }
vectorcraft-effects = { workspace = true }
vectorcraft-three-d = { workspace = true }
vectorcraft-plugins = { workspace = true }
vectorcraft-pdf = { workspace = true }
vectorcraft-cad = { workspace = true }
vectorcraft-eps = { workspace = true }
vectorcraft-format = { workspace = true }
egui = { workspace = true, features = ["bytemuck"] }
# With egui's `bytemuck`: copies rendered rasters into egui images whole (`canvas::color_image`).
bytemuck = "1"
egui_extras = { workspace = true }
image = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
log = { workspace = true }
[target.'cfg(target_arch = "wasm32")'.dependencies]
# `now_ms` (src/lib.rs) reads the page's `performance.now()` with this crate in the web build. It is
# MIT OR Apache-2.0 and already in the build through eframe.
web-time = "1"
# The current user's id (`geteuid`): Preview in Browser uses its temporary folder only when that
# user owns it (src/dialogs/save_for_web.rs). Already in Cargo.lock (tempfile), so this adds no
# new crate.
[target.'cfg(unix)'.dependencies]
rustix = { workspace = true, features = ["std", "process"] }
[dev-dependencies]
egui_kittest = { workspace = true, features = ["wgpu", "snapshot"] }
vectorcraft-testkit = { workspace = true }
# A variable font built in code (no font file is committed).
vectorcraft-text = { workspace = true, features = ["test-fonts"] }
wat = { workspace = true }
[build-dependencies]
serde_json = { workspace = true }
toml = "1"