mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-31 21:27:00 -06:00
Text: an embedder of the egui panels may leave the bundled fonts out
#2027 gave vectorcraft-text and vectorcraft-engine a `bundled-fonts` feature for an embedder that supplies every document font at run time, but vectorcraft-ui-egui (and vectorcraft-mcp) named the engine with its default features, so an embedder that hosts the panels got the fonts whatever it asked for. Each now has a `bundled-fonts` feature of its own, on by default, that turns the engine's on, so a downstream user keeps the fonts unless it asks otherwise. For a member to leave the engine's default features out, the workspace has to declare the engine without them, as it already declares vectorcraft-text; the crates that used the engine's default now ask for the fonts: the three apps and vectorcraft-testkit. Off, vectorcraft-text's copy of the fonts (3.4 MB) is left out; theme.rs's own copies of five of them, the panels' interface faces, stay either way. Nothing the workspace builds changes: for every workspace member and for the whole workspace, with and without dev-dependencies, for all targets, wasm32-unknown-unknown, aarch64-apple-darwin and x86_64-pc-windows-msvc, `cargo tree -e normal[,dev] -f '{p} [{f}]'` resolves the same features for every package as on main, apart from the new feature names (the engine's `default` no longer listed; ui-egui's and mcp's `bundled-fonts` and `default`). A test of the panels can't see their configuration without the fonts (their dev-dependencies turn them on), so `cargo xtask ci`'s `no-bundled-fonts` step now also reads that tree for vectorcraft-ui-egui and vectorcraft-mcp: with their default features it must show the fonts, and without them, for any target (a wasm-only dependency too), it must not. Documented in docs/development.md (Fonts › Leaving out the bundled fonts). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
committed by
bflatastic
co-authored by
Claude Opus 5.5
parent
6807e757af
commit
e321c7179b
+38
-1
@@ -105,6 +105,40 @@ fn run(mut cmd: Command, what: &str) -> Result<(), String> {
|
||||
if status.success() { Ok(()) } else { Err(format!("{what}: exited with {status}")) }
|
||||
}
|
||||
|
||||
/// `vectorcraft-ui-egui` and `vectorcraft-mcp` without their default features leave
|
||||
/// vectorcraft-text's bundled fonts out: no crate they depend on turns them on (docs/development.md
|
||||
/// › Leaving out the bundled fonts). The same tree with the default features must show them, so a
|
||||
/// change in cargo tree's output can't make the check pass by finding nothing.
|
||||
fn libraries_without_bundled_fonts() -> Result<(), String> {
|
||||
["vectorcraft-ui-egui", "vectorcraft-mcp"].into_iter().try_for_each(without_bundled_fonts)
|
||||
}
|
||||
|
||||
fn without_bundled_fonts(package: &str) -> Result<(), String> {
|
||||
const FEATURE: &str = "vectorcraft-text feature \"bundled-fonts\"";
|
||||
let tree = |defaults: bool| -> Result<String, String> {
|
||||
let mut args = vec!["tree", "-p", package, "--target", "all", "-e", "features,normal", "-i", "vectorcraft-text"];
|
||||
if !defaults {
|
||||
args.insert(3, "--no-default-features");
|
||||
}
|
||||
let what = format!("cargo {}", args.join(" "));
|
||||
eprintln!("$ {what}");
|
||||
let out = cargo().args(&args).output().map_err(|e| format!("{what}: failed to spawn: {e}"))?;
|
||||
if !out.status.success() {
|
||||
return Err(format!("{what}: exited with {}:\n{}", out.status, String::from_utf8_lossy(&out.stderr)));
|
||||
}
|
||||
Ok(String::from_utf8_lossy(&out.stdout).into_owned())
|
||||
};
|
||||
let with = tree(true)?;
|
||||
if !with.contains(FEATURE) {
|
||||
return Err(format!("{package} with its default features shows no {FEATURE} (has cargo tree's output changed?):\n{with}"));
|
||||
}
|
||||
let without = tree(false)?;
|
||||
if without.contains(FEATURE) {
|
||||
return Err(format!("{package} without default features still bundles the fonts:\n{without}"));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn metadata() -> Result<serde_json::Value, String> {
|
||||
let out = cargo().args(["metadata", "--format-version", "1", "--no-deps"]).output().map_err(|e| format!("cargo metadata: {e}"))?;
|
||||
if !out.status.success() {
|
||||
@@ -212,7 +246,10 @@ fn cmd_ci() -> Result<(), String> {
|
||||
// vectorcraft-text as embedders that bring their own fonts build it.
|
||||
let mut c = cargo();
|
||||
c.args(["test", "-p", "vectorcraft-text", "--no-default-features", "--test", "without_bundled_fonts"]);
|
||||
run(c, "cargo test -p vectorcraft-text --no-default-features --test without_bundled_fonts")
|
||||
run(c, "cargo test -p vectorcraft-text --no-default-features --test without_bundled_fonts")?;
|
||||
// The egui panels and the MCP server as such an embedder builds them: nothing turns
|
||||
// the fonts back on.
|
||||
libraries_without_bundled_fonts()
|
||||
}),
|
||||
),
|
||||
("pdf-deps", Box::new(|| pdf_deps::run(&root()))),
|
||||
|
||||
Reference in New Issue
Block a user