The last vertical-spring piece: the gaps BETWEEN a system's staves are renegotiated so tightly ledgered or slurred adjacent staves — which the constrained stage stacks at a fixed pitch — separate. ENGRAVER_VERSION 10 -> 11 (a multi-staff score whose staves press together shifts them apart; a single-staff score, with no inter-staff pair, is byte-identical). Attribution (vertical_band + owning-glyph, per the chosen approach): a glyph via its vertical_band (VerticalBandKind::Staff -> StaffId); a stem/ledger via its notehead (component_glyph); a staff line via its Staff source; a slur via the notehead nearest its start. Spacing is horizontal-only, so a primitive's y is unchanged from the source frame the attribution reads. The solve: per system, per staff, collect the real content y-extent (glyphs, strokes, curves — ledgers and slurs included); order staves top-to-bottom by their staff-line reference y (order fixed); shift each staff down by the cumulative amount needed to bring its gap to the one above up to the band model's preferred inter-staff gap. staff_shift[(system, staff)] is a per-staff dy the bake applies (Placement::sunk) atop the per-system dy, so glyphs, strokes, curves, the staff/measure/system records, content bounds, hit-test, and quality metrics all read the same shifted geometry. The shifts grow each system's extent, which the vertical stacking and justification then consume. Regression inter_staff_solve_separates_colliding_staves (the two-staff fixture's staff-line gap opens past the fixed pitch; a single-staff score keeps one staff per system) + the two_staff_close_content render golden updates (slice 1 tight, slice 2 separated). Only that engrave golden churned; single-staff goldens byte-stable. 947 tests, clippy 0, docs -D warnings, conformance 8/8. This completes the Standard-tier layout story end to end. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| examples | ||
| src | ||
| tests | ||
| tools | ||
| Cargo.toml | ||
| DECISIONS.md | ||
| README.md | ||
README.md
epiphany-render-svg
Agent I's SVG renderer behind the Epiphany RenderIR interface (spec
Chapter 7): turns a ResolvedLayoutIR into well-formed SVG 1.1, drawing each
glyph from genuine Bravura SMuFL data — inline outline <path>s by default
(GlyphMode::PathOutline), or <text> set in an @font-face-embedded Bravura
subset (GlyphMode::EmbeddedFont). It is the visible end of the v0
Score → layout IR pipeline.
Status
The Score → layout IR → SVG pipeline renders recognizable notation — clefs,
noteheads at clef-relative staff positions, accidentals, key/time signatures,
rests, barlines, and the staff lines and stems that connect them. Output is
golden-locked against both the interface-only stub solver and Agent I's real
epiphany-engrave solver (whose horizontal spacing pass re-spaces the glyphs),
and the layout round-trip (criterion 6) runs through both. What the renderer
itself guarantees, independent of engraving quality: real Bravura glyphs,
provenance preserved to the score graph, output XML-valid and deterministic. The
renderer consumes any solver's ResolvedLayoutIR.
Demo
# Render a fixture to SVG (stub solver by default):
cargo run -p epiphany-render-svg --example render_fixture -- \
ten_measure_single_staff > out.svg
# Drive Agent I's engrave solver instead, to bisect renderer-vs-solver:
cargo run -p epiphany-render-svg --example render_fixture -- \
ten_measure_single_staff --solver=real > out.svg
# Use the embedded-font glyph mode (<text> + @font-face) instead of inline paths:
cargo run -p epiphany-render-svg --example render_fixture -- \
ten_measure_single_staff --glyph-mode=embedded > out.svg
Fixtures: ten_measure_single_staff, valid_score_rich, valid_score. Stats and
diagnostics go to stderr; the SVG goes to stdout.
Library
use epiphany_render_svg::{render, RenderOptions};
let out = render(&resolved_layout_ir, &RenderOptions::default());
assert!(out.is_well_formed());
println!("{}", out.svg);
render is pure and deterministic. RenderOptions controls SVG-encoding choices
only (display scale, margin, provenance attributes, and glyph_mode — inline
PathOutline vs EmbeddedFont) — nothing that changes engraving.
Bundled Bravura data
Two generated artifacts come from the official OFL Bravura.otf via
tools/extract_bravura_outlines.py — the font is not vendored, only the
generated Rust is committed:
src/outlines_generated.rs— the inline glyph outlines (geometry-only, so byte-stable across fontTools versions);src/font_subset_generated.rs— a base64 OTF subset (just the pipeline's glyphs) forGlyphMode::EmbeddedFont. As a Modified Version, its primary font name is renamed off the Reserved Font Name "Bravura" per the OFL; a content BLAKE3 + decoded length are committed alongside as an integrity lock.
Bravura is © Steinberg Media Technologies GmbH under the SIL Open Font License 1.1
(tools/OFL.txt); both artifacts are redistributed under the same license. To
regenerate both (the subset step also needs the blake3 package):
cd crates/epiphany-render-svg/tools
python3 -m venv .venv && . .venv/bin/activate && pip install fonttools blake3
python3 extract_bravura_outlines.py --font-out ../src/font_subset_generated.rs \
> ../src/outlines_generated.rs